Selecting specific image size fails and falls back to "full" when large image is scaled

If a specific image size is selected in the builder to display AND the image has been scaled down due to it being a large resolution (https://make.wordpress.org/core/2019/10/09/introducing-handling-of-big-images-in-wordpress-5-3/), the internal function mfn_get_attachment_id_url fails.

This function uses a custom database query that is looking for a GUID that doesn't exist.

The image itself has "-scaled" appended to the filename, but the GUID in the database remains as the original. The image_url and the guid therefore do not match in the query.

The function is obsolete, as there is a built in function that does the same - and effectively.

Can you please either remove mfn_get_attachment_id_url or use the WP function of attachment_url_to_postid (which has been in place since WP V4.0) inside it?

Comments

  • edited October 2022

    To reproduce:

    1. Upload a 2560px+ image
    2. Create a page and insert an image element
    3. Choose "Medium" as the size
    4. Save
    5. Inspect the source of the output
    6. You will see the image is not the medium size

    To fix:

    1. Short term
      1. Replace the contents of the function mfn_get_attachment_id_url with `return attachment_url_to_postid($image_url);`
    2. Long term
      1. Remove all references to mfn_get_attachment_id_url to replace with `return attachment_url_to_postid($image_url);`
  • Hi,

    Thanks for reporting.

    I have passed this problem to the dev team, and we will fix it as soon as possible.


    Best regards

  • Great, thanks

Sign In or Register to comment.