Archived topic
Featured image shortcode: how to pick right image size?
3 replies · Started by Marc on July 4, 2020
Hi there,
I created a header element, with a shortcode for the featured image like suggested here:
- https://generatepress.com/forums/topic/featured-image-shortcode/
Works great!
However, it seems to pick the full size image? Actually I only need a 254x254px image. Is there a way to pick the 300x300px version of the image that gets created when uploading a square image?
Hi there,
change this line:
return get_the_post_thumbnail($post->ID);
to:
return get_the_post_thumbnail($post->ID, 'thumbnail' );
More info on that function here:
https://developer.wordpress.org/reference/functions/get_the_post_thumbnail/
Thnx David!
'thumbnail' seems a bit too small in some cases, however 'medium' looks good so far! :-D
Glad to hear that