WPML

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

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

  • 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;
};
}

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

ยังคงพบปัญหานี้อยู่หรือไม่

หากการอัปเดตไม่สามารถแก้ไขปัญหานี้ได้ ส่งคำถามถึงฝ่ายสนับสนุน และเราจะตรวจสอบร่วมกับคุณ