WordPress.org

Ready to get started?Download WordPress

Forums

A simple the_post_thumbnail(); issue (3 posts)

  1. joaoramos
    Member
    Posted 3 years ago #

    Hi,

    I coded both my loop.php & functions.php to print a 225x150 featured image but it's printing a default 150x150 image instead, as shown below:

    in functions.php:

    <?php
    	if (function_exists('add_theme_support')) {
    		add_theme_support('post-thumbnails');
    		set_post_thumbnail_size(225, 150, true);
    	}
    ?>

    in loop.php:

    <?php
    	if (has_post_thumbnail()) {
    		$size = array(225, 150);
    		the_post_thumbnail($size);
    	}
    ?>

    Here's the <img> the loop is currently printing:

    <img width="150" height="150" src="XXX/avatar_1a2-150x150.jpg" class="attachment-225x150 wp-post-image" alt="Resetting everywhere." title="Resetting everywhere.">

    As you can see, those width and height HTML attributes shouldn't have those values. Also, the filename should end as "225x150.jpg" instead of "150x150.jpg". Right? Any suggestions? It's my very first WordPress redesign from scratch. Oh, the excitement! Thank you :)

  2. joaoramos
    Member
    Posted 3 years ago #

    Problem just solved. As it seems, there's no way to do this programmatically. I just had to go to Settings > Media and change the "Thumbnails" width and height values by myself. I do think WordPress should somehow overwrite those values by the ones force on the template (like I stated above), though. Thank you.

  3. Rev. Voodoo
    Volunteer Moderator
    Posted 3 years ago #

    hmmm.... thats how it works for me?

    I have my settings->media thumbnails at 150x150

    But I use various thumbnails all over the place, in 6 sizes

    for example

    <img width="205" height="100" src="http://www.rvoodoo.com/empire/wp-content/uploads/2010/12/voodooW-205x100.jpg"

Topic Closed

This topic has been closed to new replies.

About this Topic