Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use standard (or custom) post thumbnail (AKA featured image) size #131

Closed
henryk opened this issue Aug 12, 2014 · 2 comments

Comments

Projects
None yet
2 participants
@henryk
Copy link
Contributor

commented Aug 12, 2014

Moin,

Currently

<?php the_post_thumbnail( array( 700, 700 ), array( 'itemprop' => 'image' ) ); ?>
specifies the featured image size as array( 700, 700 ). This leads to wordpress doing something rather silly:

<img width="700" height="525" src="https://…-1024x768.jpg" class="attachment-700x700 wp-post-image" alt="" title="" itemprop="image" />

i.e. it scales the image using HTML width/height attributes (my base image had a 4:3 aspect) and picks the closest already available size (1024x768 in my case).

Obviously, scaling in the browser should be avoided if possible, for better bandwidth efficiency and rendering speed.

http://codex.wordpress.org/Post_Thumbnails recommends to use a string instead of the size array as the first argument to the_post_thumbnail, which means a prescaled image might already be available. There's two options: Use the predefined post-thumbnailsize by changing it to 700x700 with http://codex.wordpress.org/Function_Reference/set_post_thumbnail_size or define a new image size with http://codex.wordpress.org/Function_Reference/add_image_size.

I've successfully tested the latter variant by adding

add_image_size( 'independent_publisher_post_thumbnail', 700, 700);

below

add_theme_support( 'post-thumbnails' );

and changing the array( 700, 700 ) to "independent_publisher_post_thumbnail" in the content-single.php line mentioned above. The code generated by wordpress now reads (after uploading a new image)

<img width="700" height="525" src="https://…-700x525.jpg" class="attachment-independent_publisher_post_thumbnail wp-post-image" alt="" title="" itemprop="image" />

Henryk Plötz
Grüße aus Berlin

@raamdev raamdev added the enhancement label Aug 12, 2014

@raamdev raamdev added this to the Next Release milestone Aug 12, 2014

@raamdev

This comment has been minimized.

Copy link
Owner

commented Aug 12, 2014

@henryk Thank you for the report! I will get this fixed for the next update. :)

@raamdev raamdev closed this in a65b5fb Aug 12, 2014

@raamdev

This comment has been minimized.

Copy link
Owner

commented Aug 12, 2014

@henryk This has been fixed in the development branch and will go out with the next release. Thanks so much for your detailed report. The way you explained things saved me a lot of work! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.