• Resolved TheImperial

    (@theimperial)


    Hi guys,

    I’ve got two query_posts set up outside of my loop that display thumbnail images. This is the first time I’m using the thumbnail feature and have got something wrong.

    I thought I had specified the correct code, but instead of showing the resized image I uploaded (e.g. /wp-content/uploads/2010/11/filename.jpg), it instead outputs the 150×150 thumbnail (e.g. /wp-content/uploads/2010/11/filename-150×150.jpg)

    Here is the code I am using for the first query:

    <?php query_posts('cat=1&showposts=4'); ?>
    <?php while (have_posts()) : the_post(); ?>
    	<li><a href="<?php the_permalink() ?>" title="Read <?php the_title(); ?>">
    	<?php
    		if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) {
    			the_post_thumbnail(array( 130,48 ), array('class' => 'framed', 'width' => '130', 'height' => '48'));
    		} else
    			echo '<img src="' . get_bloginfo('template_directory') . '/images/thumb_4xlt.jpg" class="framed" height="48" width="130" />';
    	?>
    	<?php the_title(); ?><span class="subtext"><?php the_time('D F d Y') ?></span></a>
    	</li>
    <?php endwhile;?>

    And the second:

    <?php query_posts('tag=featured&showposts=1'); ?>
    	<?php while (have_posts()) : the_post(); ?>
    		<a href="<?php the_permalink() ?>" title="Read <?php the_title(); ?>">
    		<?php
    			if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) {
    				the_post_thumbnail(array( 330,126 ), array('class' => 'framed', 'width' => '330', 'height' => '126'));
    			} else
    				echo '<img src="' . get_bloginfo('template_directory') . '/images/thumb_4xlt.jpg" class="framed" height="126" width="330" />';
    				?>
    				<p><?php the_title(); ?><span class="subtext"><?php the_time('D F d Y')?></span></p></a>
    <?php endwhile;?>

    Oddly enough, this code is a dang near duplicate of what I use in the Loop, and it displays the correct image. I’m not sure what I’m going wrong here, and I could really use your expert eyes giving this a look!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter TheImperial

    (@theimperial)

    Had a different thought regarding image use.

    Is this simply indented functionality outside of the Loop, and I’ll have to add something to functions.php?

    As I have two different sizes in use, is setting set_post_thumbnail_size( ); in functions.php a viable route, if I set it to the largest size?

    Thread Starter TheImperial

    (@theimperial)

    Turns out it was as simply as that – with a twist.

    Added the following lines to my functions.php to set new image sizes:

    add_image_size( 'thumbnail-1x', 130, 48 ); // Permalink 1x Col Thumbnail
     add_image_size( 'thumbnail-2x', 330, 126 ); // Permalink 2x Col Thumbnail

    After that, it was just a matter of adding ‘thumbnail-1x’ or 2x to the_post_thumbnail.

    This is where it got kinda tricky for a php newb like myself. Adding in the preset image size name replaced all the other content in the_post_thumbnail, specifically the class.

    So, the easiest way around this was simply to replace the class with very specific css that would target these images. Perhaps not the most elegant or lightweight solution, but I’ll take it for now.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Specify Full Sized Featured Image & Not 150×150 Thumbnail?’ is closed to new replies.