0

So here's my problem: I have a site with several articles on the homepage, these are using the featured image as a thumbnail (roughly 250x250). Then, for a single article (single.php) I'm using the same image (with the same call get_post_thumbnail). The issue is, I don't need to be loading 1600x800 images for thumbnails, but I do for display on a single article.

I've looked in to plugins like Multiple Featured Images so I could just have 2 different sizes of the same image, but this would require me to go back through every article and upload a scaled down image.

Basically, I want to upload one image, but use 2 different sizes of it for site speed reasons.

Any ideas?

1 Answer 1

0

Wordpress has built in sizes for your photos that it automatically creates when you upland an image.

You can call different ones by using

get_the_post_thumbnail( $post_id, 'thumbnail' );      // Thumbnail (Note: different to Post Thumbnail)
get_the_post_thumbnail( $post_id, 'medium' );         // Medium resolution
get_the_post_thumbnail( $post_id, 'large' );          // Large resolution
get_the_post_thumbnail( $post_id, 'full' );           // Original resolution

if those don't fit exactly what you're looking for you can create your own size too:

add_image_size( 'my-custom-size', 220, 180 ); // 220 pixels wide by 180 pixels tall, soft proportional crop mode

and then call it by the same as above:

get_the_post_thumbnail( $post_id, 'my-custom-size' );      

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.