In Word Press, how do I scale thumbnails down a percentage in PHP?

ThankDog used Ask the Experts™
Hi, I'm using word press for my blog.  The home page calls the pictures from each post to appear as a thumbnail above the text.  The thing is...instead of it resizing the picture to a certain percentage and keeping it proportional, it literally sizes it down and then clips the picture to fit 120 x the picture is not only super small, but totally cut off.  I want the picture to be big enough to see and to be proportional... 

Here is the php code:


/* sets predefined Post Thumbnail dimensions */
if ( function_exists( 'add_theme_support' ) ) {
      add_theme_support( 'post-thumbnails' );
      //home.php, index.php, single.php
      add_image_size( 'homepage', 120, 120, true );

      //page image size
      add_image_size( 'pageimage', get_option($shortname.'_thumbnail_width_pages'), get_option($shortname.'_thumbnail_height_pages'), true );
/* --------------------------------------------- */


Thanks a ton!!!!
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
add_image_size( 'homepage', 120, 120, true );

Change the numbers to the size you want the thumb.  The 1st one is width, the 2nd is height.

Remove , true to stop the hard cropping.  false is the default.


I used what he suggested and then found out I gave the wrong code so it didn't work.  But because of that, I was able to tweak the code I found to what he said and it worked!


Hi gwkg...first, thank you for your time. I realized I gave the wrong PHP code that was actually doing the controlling, so when I used what you said it didn't work. However, when I realized there was another php file, I took your guidance and edited the block of coding with better understanding....

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                                          <?php $thumb = '';
                                                  $width = 350;
                                                  $height = auto;
                                                  $classtext = '';
                                                  $titletext = get_the_title();
                                                  $thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext, true);
                                                  $thumb = $thumbnail["thumb"]; ?>


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial