WPML
สถานะ
แก้ไขแล้ว
แก้ไขใน
2.3.0

ภาพรวมของปัญหา

บางครั้ง คุณอาจพบข้อผิดพลาดร้ายแรงต่อไปนี้:

  • Fatal error: Uncaught exception ‘InvalidArgumentException’ with message ‘Argument ID must be numeric and greater than 0’

ปัญหานี้เกี่ยวข้องกับปลั๊กอิน WPML Media Translation ข้อผิดพลาดนี้เกิดขึ้นหากคุณมีรูปภาพที่ไม่มีข้อมูลไฟล์แนบและเป็นเพียงลิงก์แบบสัมบูรณ์ไปยังรูปภาพ

วิธีแก้ปัญหาชั่วคราว

ปัญหานี้จะได้รับการแก้ไขในเวอร์ชันที่เผยแพร่ในอนาคต สำหรับวิธีแก้ปัญหาชั่วคราว คุณสามารถทำตามขั้นตอนต่อไปนี้


  1. แก้ไขไฟล์ class-wpml-media-image-translate.php ที่อยู่ในโฟลเดอร์ ../wpml-media-translation/classes/images-translation/

  2. ใช้โค้ดต่อไปนี้เพื่อแทนที่ฟังก์ชัน get_translated_image_by_url
public function get_translated_image_by_url( $img_src, $source_language, $target_language ){

$attachment_id = $this->get_attachment_image_from_guid($img_src, $source_language);
if (!$attachment_id) {
$attachment_id = $this->get_attachment_image_from_meta($img_src, $source_language);
}
if ($attachment_id){
$size = $this->get_image_size_from_url($img_src, $attachment_id);

return $this->get_translated_image($attachment_id, $target_language, $size);
} else {
return $img_src;
};
}

ปัญหาที่ทราบแล้วทั้งหมด →