- Status
- Resolved
- Resolved in
- 2.3.0
Overview of the issue
Sometimes, you might encounter the following fatal error:
- Fatal error: Uncaught exception ‘InvalidArgumentException’ with message ‘Argument ID must be numeric and greater than 0’
This issue is related to the WPML Media Translation plugin. It happens if you have an image that has no attachment data and is just an absolute link to the image.
Workaround
This issue will be fixed in the future release. As a temporary workaround you can use the following steps.
- Edit the class-wpml-media-image-translate.php file found in the ../wpml-media-translation/classes/images-translation/ folder.
- Use the following code to replace the get_translated_image_by_url function.
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;
};
}