Resolved

Resolved in: 2.3.0

Topic Tags: Media Translation

Symptoms

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.

  1. Edit the class-wpml-media-image-translate.php file found in the ../wpml-media-translation/classes/images-translation/ folder.
  2. 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;
};
}

13 Responses to “Fatal error: Uncaught exception ‘InvalidArgumentException’ with message ‘Argument ID must be numeric and greater than 0’”

  1. I found the same issue.
    This workaround solves it but …. it is a dirty hack.

    Why an image would not have it’s attachment_id?

    Anyone with a more elegant solution?

  2. WPML Media is causing some of my websites not to upload files (PDFs or Images). It gives the red warning HTTP ERROR 500.

    Now for some reason, I cannot open a ticket anymore… You guys hid the CREATE NEW TICKET pretty well……..

    • When you go to our support forum, you first see a search. Please have a look right below the search. There’s a link to skip the search and open a ticket. You need to be logged-in to wpml.org in order to create new support tickets.

      • Yes I noticed that after posting here. It seems to be a trend now to offer suggestions before opening a ticket 😉 Thanks Amir!

        Any news on the error with WPML Media? In any case, I opened a ticket hoping this can be resolved..

        • Hello.

          As many other does, we provide suggestions before opening a ticket because, most of the times, the answer or the solution to the issue is already available.

          As for the WPML Media error, it seems like you did not create a ticket in the forum yet and personally, I’m not aware of an issue like the one you described.

          Please create the ticket in the forum, so we can properly track and troubleshoot the issue.

    • Hello!
      Did you update WPML Media Translation?
      If you did, and the issue is still happening, probably it is a best if you open a new ticket in our forum so that our support specialists can help you.