Horje
the_post_thumbnail sizes not working properly - Wordpress Solution
[Solved] - the_post_thumbnail sizes not working properly - Wordpress Solution
Try following codes
I am trying to use the_post_thumbnail to display some thumbnail images on one of our pages. I have set
	<? the_post_thumbnail(array(291,167)); ?> 
However when I upload the images, they are all getting weird sizes. Some show up as 291x160, some 280x140 and other weird sizes. Is there any way to have the_post_thumbnail size the images the exact same size regardless of their original size? Alternatively, Is there a way for WP to crop them to that size instead of trying to shrink fit?

Solution - 1

Make sure in your functions.php you have this -


add_theme_support( 'post-thumbnails' );
add_image_size( 'single-post-thumbnail', 291, 168, true );
Then in your template do this -

<?php the_post_thumbnail( 'single-post-thumbnail' ); ?>
Then you can use this plugin to regenerate your thumbnails. http://wordpress.org/extend/plugins/regenerate-thumbnails/


Solution - 2

which theme you are using. check your themes functions.php file to check whether default thumbnail size is added using following function


 set_post_thumbnail_size( ); // default Post Thumbnail dimensions   
for more details of this function check http://codex.wordpress.org/Function_Reference/set_post_thumbnail_size or for more details of this function check

<?php add_image_size( $name, $width, $height, $crop ); ?> 
http://codex.wordpress.org/Function_Reference/add_image_size


Solution - 3

Hi, take a look at this video: [[LINK href="http://www.youtube.com/watch?v=SNSoqzRA_IY"]]Crop[[/LINK]] You can use it to crop images to exact size you need.

Date: 2022-10-21 05:13:41
Category: Wordpress
More for You