Uploaded image for project: 'Planet4'
  1. Planet4
  2. PLANET-6372

Some images disappear because they use a path on the server instead of the CDN URL

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Must have Must have
    • 2.70.1
    • 3
    • Media Library

      Because of a bug in WPML's media plugin, some URLs automatically get replaced with the non CDN URL.

      This is because that plugin does the following:

      • search the post for image URLs (\WPML_Media_Post_Images_Translation::translate_images)
      • for each image URL it uses a WP function to get the attachment ID (attachment_url_to_postid)
      • for each ID construct the URL by calling wp_get_upload_dir, and concatenate it concatenate it with the path for the image ID
      • compare that URL to the URL it started from in the post content.
      • if there's any difference in the whole URL it uses the new value

      It's unclear yet in which cases this runs, but it's definitely this code that is causing it. When an affected post was fixed, the above didn't seem to run, as the page then on the front end would again use the correct paths. Probably specific conditions are needed (editor language, session language,maybe only when updating meta in CI or in the context of another filter).

      Secondary issue

      Another nasty effect of the plugin is that it modifies the post_content directly, but doesn't modify the revision. As a result, the WP revision view doesn't include these changes, which is very confusing and might cause other problems.

      Original description

      In some cases uploading images that are exactly 2560 pixels wide or high results in the Carousel Header block (perhaps also other blocks) translated images using a 404 URL.

      This 404 URL is the original file name. However the image only exists with "-scaled" appended before the file extension, even though the image has the exact same dimensions. We were on the wrong track here. WP media library has a link to the original, however the stateless plugin doesn't preserve this. That is only an issue if you need to regenerate sizes at a later point.

      Interestingly the affected images show a link to the original image which is a 404. If I re-upload the same image, I do not see that link. However I noticed that today an image uploaded by someone else on BE also had the issue.

      I tried reproducing the issue and was not able to (tried on dev and staging sites for BE). For me what happened was that it does actually correctly use the URL with "-scaled" at the end.

      I tried uploading the image from /media/upload.php and from an image block. In neither cases did it result in the issue.

            pvincent Pieter Vincent
            pvincent Pieter Vincent
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: