[Resolved] Featured image shortcode: how to pick right image size?

Home Forums Support [Resolved] Featured image shortcode: how to pick right image size?

Home Forums Support Featured image shortcode: how to pick right image size?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1351768
    Marc

    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?

    #1351821
    David
    Staff
    Customer Support

    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/

    #1353002
    Marc

    Thnx David!

    ‘thumbnail’ seems a bit too small in some cases, however ‘medium’ looks good so far! 😀

    #1353402
    David
    Staff
    Customer Support

    Glad to hear that

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.