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.
This website uses cookies

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you’ve provided to them or that they’ve collected from your use of their services.

Cookies are small text files that can be used by websites to make a user's experience more efficient.

The law states that we can store cookies on your device if they are strictly necessary for the operation of this site. For all other types of cookies we need your permission. This means that cookies which are categorized as necessary, are processed based on GDPR Art. 6 (1) (f). All other cookies, meaning those from the categories preferences and marketing, are processed based on GDPR Art. 6 (1) (a) GDPR.

This site uses different types of cookies. Some cookies are placed by third party services that appear on our pages.

You can at any time change or withdraw your consent from the Cookie Declaration on our website.

Learn more about who we are, how you can contact us and how we process personal data in our Privacy Policy.

Please state your consent ID and date when you contact us regarding your consent.