WPML
状态
已解决
解决于
2.3.0

问题概述

有时,您可能会遇到以下致命错误:

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

此问题与 WPML Media Translation 插件有关。如果您的图像没有附件数据,而仅仅是该图像的绝对链接,就会发生这种情况。

临时解决方法

此问题将在未来的版本中修复。作为临时解决方法,您可以使用以下步骤。


  1. 编辑 ../wpml-media-translation/classes/images-translation/ 文件夹中的 class-wpml-media-image-translate.php 文件。

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

所有已知问题 →