I am working on the WordPress Twenty Ten theme, and I want to display post thumbnails. I have followed the steps below:
-
Added following code in functions.php file:
if ( function_exists( 'add_theme_support' ) ) { add_theme_support( 'post-thumbnails' ); }
-
I have also defined post thumbnail size,
set_post_thumbnail_size( 150, 150 );
-
And I configured the media settings from the admin panel of WordPress to not to crop image. but this is cropping the image.
-
Using this in loop.php file,
the_post_thumbnail(array(150,150);
I do not want to crop the image. How can I do this? Please help where I am wrong in my process.
Thanks in advance.
IF you want to retrieve thumbnail in size that you had set with
set_post_thumbnail_size()
then callthe_post_thumbnail()
without passing any arguments.That will default to named
post-thumbnail
size that thatset_post_thumbnail_size()
actually creates.Also crop for this will be determined by third argument in
set_post_thumbnail_size()
(defaults tofalse
) and is not tied to media settings (those control entirely different sizes of image).Maybe it’s just a typo, use
instead of
Another thing is, I’ve never used this in the loop.php only in functions.php
A couple things to try:
Create a new custom image size:
add_image_size( 'my-custom-thumb', 150, 150 );
Play around with the dimensions, to see how WordPress reacts. There may be a collision, since there is already a 150×150 image size.Regenerate your thumbnails, using the Regenerate Thumbnails Plugin or the Ajax Thumbnail Rebuild Plugin.
And, as @Rarst said: remove the array from the call to
the_post_thumbnail()
; either pass it no parameters, or pass it animage-size-name
as an argument.