Results 1 to 4 of 4

Thread: Timthumb placeholder image

  1. #1
    DancingK is offline Hello World
    Join Date
    Jan 2012
    Posts
    3

    Default Timthumb placeholder image

    I've installed a theme (Chronicle) that's using timthumb for thumbnails.

    It seems the thumbnails work fine if I add an image to a post, but without an image it shows an empty X box on the index page post.

    The Thumbnail is called via this :

    Code:
    <img class="ethumb" src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php echo $preview; ?>&amp;h=100&amp;w=290&amp;zc=1" alt=""/>
    I've tried replacing the <?php echo $preview; ?> as some other help files have suggested but this over writes any other featured images I've uploaded on other posts.

    I have seen a loop which seems to do what I want only when I try to use code or anything like this it throws a php error:

    Code:
    <?php $i = 0; while ( $q->have_posts() ) : $q->the_post(); 
    		  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
    		  $image = $image[0];
    		  
    		  if(empty($image)){
    			  $image = 'http://www.mysite.com/wp-content/uploads/2011/XX/placeholder.jpg';
    		  }
    	?>
    FYI: The image url above is one I've made up for this forum.

    I'd simply just like for a particular image to be used when and only when another image isn't uploaded. Does anyone know the best way to solve this ?

  2. #2
    Jeffro's Avatar
    Jeffro is offline WPTavern Forum Admin
    Join Date
    Jan 2009
    Location
    Ohio
    Posts
    2,359

    Default

    While I can't help you with the TimThumb stuff, have you tried messing around with Justin Tadlocks, Get The Image script?

    http://wordpress.org/extend/plugins/get-the-image/

    You might find out that you can accomplish what you want via that plugin.

  3. #3
    DancingK is offline Hello World
    Join Date
    Jan 2012
    Posts
    3

    Default

    Quote Originally Posted by Jeffro View Post
    While I can't help you with the TimThumb stuff, have you tried messing around with Justin Tadlocks, Get The Image script?

    http://wordpress.org/extend/plugins/get-the-image/

    You might find out that you can accomplish what you want via that plugin.
    Thank You, I found an alternative fix for the theme I'm using (Chronicle) but the plugin you mentioned will most likely come in very handy with any future builds.

    For future reference if anyone else has the same problem, here's the fix I found:
    Code:
    <div class="sentry">
    <?php if ($preview = get_post_meta($post->ID, 'preview', $single = true)) { ?>
    <img class="ethumb" src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php echo $preview; ?>&amp;h=100&amp;w=290&amp;zc=1" alt=""/> 
    <h2><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
    <?php the_excerpt(); ?> 
       <?php } else { ?>
    <img src="http://domain.com/wp-content/uploads/DEFAULT_IMAGE.jpg" width="290" height="100" alt=""  />
    <h2><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
    <?php the_excerpt(); ?>
       <?php } ?> 
    <div class="clear"></div>
    </div>

  4. #4
    chipbennett's Avatar
    chipbennett is offline WordPress Legend
    Join Date
    Feb 2009
    Location
    St. Louis, MO
    Posts
    1,997

    Default

    For "future builds" of your Theme, I would recommend using thumbnail generation built in to WordPress core, rather than using a third-party thumbnail-generation script.
    WP TurnKey - Turn-Key WordPress installation and maintenance services
    WordPress user since 2005 | @chip_bennett | chipbennett.net | cbnet Plugins

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •