Featured image size not working

Hey all, I’m trying to build a Wordpress loop of my posts but I want to use smaller-size images as preview. Right now, I can only build it with the default Featured Image data source:

Schermata 2022-08-15 alle 11.13.08

That works, but as soon as I choose one of the others (SM, MD, LG or even Full) they just don’t appear, and leave the PlaceholderImg instead. Like this:

I tried to switch to data source URL and use one of the short codes, but they also don’t work. I outputted them to my page to see what they get turned into, and this is what I get:

%WP_thumbURL%: https://cirocontinisio.com/wp-content/uploads/2015/02/Tobii3.png
%WP_thumbSmURL%: https://cirocontinisio.com/wp-content/themes/ciro/img/placeholder-image.png
%WP_thumbMedURL%: https://cirocontinisio.com/wp-content/themes/ciro/img/placeholder-image.png
%WP_thumbLgURL%: https://cirocontinisio.com/wp-content/themes/ciro/img/placeholder-image.png
%WP_thumbFullURL%: https://cirocontinisio.com/wp-content/themes/ciro/img/placeholder-image.png
%WP_thumbTitle%: Tobii3

So as you can see the full size image is there (but only if using thumbURL, not thumbFullURL!) and its name. But the others are left on the placeholder-image.

PS: I double checked, the images are on the server, they are in the DB, and if I install another WP template, it can correctly retrieve the smaller size thumbs. So I don’t think it’s a setup issue.

Blocs bug, Wordpress issue, or am i doing something wrong? Thanks in advance!

Bump. Does anyone have thoughts on this? My site went live, but as you can see it’s quite heavy due to this issue.

Thanks!

Bumping up one more time. Any idea?

After much looking and investigating, I found the issue!

When requesting the featured image, because Blocs generates get_the_post_thumbnail_url() without arguments, which correctly produces the big featured image.

When requesting an image of a different size than the featured image though, Blocs generates get_the_post_thumbnail_url('medium'), get_the_post_thumbnail_url('small'), etc. specifying the correct size. The problem is, the function’s first parameter is not the size, but the post ID. So the function fails, returns false, and the php page displays the placeholder image instead.

To fix it, I had to go into all my Blocs-generated .php files and provide null as a first argument, like this:

get_the_post_thumbnail_url(null, 'medium')

Images display correctly now.

I hope the bug gets fixed, or at least that this thread helps someone looking into it.

3 Likes

Thanks for sharing your solution. I’m not into Wordpress at all, but surely someone else might find this useful.

I just saw this post, nice debugging job!

did you file a bug report and/or chimed in @Norm?