• Currently I have recently added content in my sidebar and it’s currently loading the thumbnail size images (150 x 150) but when testing the site in Google Page Speed it’s recommending that I serve scaled images. I believe to fit the sidebar the images are being cropped to 115 x 115. How do I correct the thumbnail size from 150 x 150 to 115 x 115? I would like to keep the thumbnail sizes at 150 x 150 for the rest of the site.

    This is the current html code:

    <?php

    $recentPosts = new WP_Query();
    $recentPosts->query(‘showposts=6’);

    echo “<div class=’recentthumbs’>”;
    while ($recentPosts->have_posts()) : $recentPosts->the_post();
    if (has_post_thumbnail) {
    echo ““;
    the_post_thumbnail(‘thumbnail’);
    echo “
    “;
    }
    endwhile;

    echo “<div style=’clear:both;’></div></div>”;
    ?>

    Thank you for your assistance, code is definitely an area where I lack any experience.

    Grace

Viewing 1 replies (of 1 total)
  • Hi, miavitadolce.

    Add this to your functions.php:
    add_image_size( 'thumb-115', 115, 115, true ); // 115 pixels wide by 115 pixels tall, hard crop mode

    Change your code in this:

    <?php
    
    $recentPosts = new WP_Query();
    $recentPosts->query('showposts=6');
    
    echo "<div class='recentthumbs'>";
    while ($recentPosts->have_posts()) : $recentPosts->the_post();
    if (has_post_thumbnail) {
    echo "";
    the_post_thumbnail('thumb-115');
    echo "";
    }
    endwhile;
    
    echo "<div style='clear:both;'></div></div>";
    ?>

    If you did not, after making changes above, install this plugin:
    http://wordpress.org/plugins/regenerate-thumbnails/

    Go, Tools >> Regenerate Thumbnails >> Click Regenerate Thumbnails.

Viewing 1 replies (of 1 total)
  • The topic ‘Related Content Widget’ is closed to new replies.