Wordpress thumbnail creation question
I'm trying to use Wordpress' built-in thumbnailing and image re-sizing in my Wordpress 2.9.2 installation. I'm trying to get various sizes (post listing/results 160x160 & "single.php" 618x150) and for some reason the single.php one works, but only half way. Not sure if I'm doing something wrong here.
I have it working…sorta. I’m totally stuck and there seems to be a lack of documentation on the Codex for this feature so here goes.
The small 160×160 thumbnail for article listings/search views works fine. It crops it, all’s groovy. The issue comes when I go to format the image for the 开发者_开发百科single.php article details view. It crops, but then scales down even further for some reason.
Screenshot:
http://c1319072.cdn.cloudfiles.rackspacecloud.com/4-15-2010%204-56-46%20PM.png
NOTE: every time I re-test this I’m completely deleting the image from the media section and re-uploading the image entirely. I also have the re-create thumbnails plugin so I know it’s not caching.
Here is my code included in "functions.php". This will help in debugging.
add_theme_support( ‘post-thumbnails’ );
set_post_thumbnail_size( 160, 160, true ); // Normal post thumbnails
add_image_size( ’single-post-thumbnail’, 618, 150, true ); // Permalink thumbnail size
I just wrote a detailed post regarding the wordpress post thumbnails a few days ago, you might find it very useful as it is very detailed.
How to use Post Thumbnails Feature in Wordpress!
I had similar problems trying to get it to work and finally went with TimThumb. I simply love it's simplicity and effectiveness. It works great, has cache capabilities and it's fast and easy.
Official site (includes tutorial): http://www.darrenhoyt.com/2008/04/02/timthumb-php-script-released/
And here's an example on how I call it in my Wordpress:
<img src="<?php echo bloginfo('template_url'); ?>/thumb.php?src=<?php echo get_post_meta($post->ID, "image", $single = true); ?>&h=75&w=75&zc=1&q=90" alt="<?php the_title(); ?>" />
(loads the image URL from a custom field of the post and resizes it to 75x75 and 90% quality)
精彩评论