• Hi there,

    I realised that the featured image on top of blog posts is causing a CLS value in Google PageSpeed of around 0.10 – now I have deactivated the featured images on top of each post completely.

    The reason seems to be this line of code:
    the_post_thumbnail( ‘ashe-full-thumbnail’ );

    And then a 300x300px image is loaded and downsized to 200x200px – the theme developers could not fix it and suggested to reach out to the core team. Not sure if there would be any way to load the post thumbnail in a way that it is not scaled down and the wight and height attributes are matching the picture…?

    But probably in one of the next versions this can be considered.

    Thx,
    Mirko

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi @mseb

    The thumbnail size ashe-full-thumbnail is defined by the theme authors for their theme stating the width and height of an image to be used. I am assuming 200x200px based on what you mentioned. This causes new image uploads to be resized in this new size too, in addition to what Core does:

    Thumbnail : (150px square)
    Medium size : (maximum 300px width and height);
    Large size : (maximum 1024px width and height);
    Full size : (full/original image size you uploaded).

    But when this new image size was added, it doesn’t automatically generate this newly defined size image for images that have already been uploaded. To regenerate them you can use this plugin – https://ww.wp.xz.cn/plugins/regenerate-thumbnails/

    That being said, its a common practice to load 2x size of the image to make it look crisp on retina screens (think iPhone, MacBook etc)

    Now, if I recall right, when there isn’t an exact fit available in terms of size, WordPress will try to return one size above the asked size to show it properly, which seems to be what is happening in your case. So regenerating the right image sizes should fix it.

    Before you do this, does this happen on a new post/page you create and upload a big image for, as well? If so, then the issue could be something else. Try to look in your theme’s code to see what’s the dimension of image size defined by ashe-full-thumbnail size.

    Thread Starter mseb

    (@mseb)

    Hi there,

    Thanks for the great and detailed feedback, I just checked it in more detail.

    Actually ashe-full-thumbnail is defined as 300x300px in the media settings, but then I would expect that the picture is then also rendered with 300px and not somehow magically downsized to 200x200px, loading and requesting the 300x300px image.

    Funny enough there are 200x200px versions of the pictures available, just exchanging the URL of the 300x300px image is proving that, but in the media settings there is no definition of any 200x200px size, hence rebuilding thumbnails does not even offer me the 200x200px size (well, I guess not required if the 200×200 version does exist).

    Any suggestion you would have? Probably creating a new size name with 200×200 and replacing “ashe-full-thumbnail” by this one in the code?

    What’s the desire size of the image that you want the theme to load? And what’s the size of the container in which this image is loaded?

    Can you share a url to such page?

    And can you provide a screenshot of this page in admin? /wp-admin/options-media.php Settings > Media

    Thread Starter mseb

    (@mseb)

    I would be happy with 200×200… as somehow these dimensions are defined as width and height while loading in the img src, apparently by the WordPress function the_post_thumbnail but if easier also 300×300 should be fine.

    Just tried to add a 200×200 size and use that, but then it takes 225×300…

    Try this url:
    https://www.wroclawguide.com/en/have-you-been-to-these-unusual-cafes-in-wroclaw/

    And here screenshot of media:
    https://www.dropbox.com/s/4q2sh1j6qwo559h/media.PNG?dl=0

    Thanks again!

    Woah, that’s a lot of image sizes.

    I already see the image at 200×200, but it should be 300×300 because its defined that way. Huh.. I am not too sure why would that be happening.

    But still 200×200 works for you, right?

    Thread Starter mseb

    (@mseb)

    Yes, indeed, I don’t even know how that happened 🙂

    However I am left with the fact that based on the size a 300×300 is requested (and coming) but then downsized to 200×200… Adding the new 200×200 size unfortunately also did not work out. Would that be a bug somewhere to be reported or any suggestions?

    Unless we have finalise reproduction instructions to produce this issue reliably, we can’t file a bug report as it’s probably the codebase of your install which overall emits this behaviour.

    And to further diagnose this issue, sorry but the only option, I see, is to use a debugger to actually go through the functions to see what’s the data flowing through them and figure out where it might be going off the expected road.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘CLS issue with the_post_thumbnail’ is closed to new replies.