• I am having problems implementing the code for displaying the first image of a post. I am using the ‘catch_that_image’ code but that shows up is the image path. I added the code to the functions.php file and to the loop of my page. Not sure why I just get the path.
    Anyone else have this problem or know how to fix it?
    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter djlender

    (@djlender)

    I’m still having problems with this. Does anyone have any ideas? I’d very much appreciate it. ??

    Hi you need to call the catch_that_image function as the source of your image tag, like:

    <img src="<?php bloginfo('template_directory'); ?><?php echo catch_that_image() ?>" alt="" />

    Thread Starter djlender

    (@djlender)

    smrdo,
    Thanks for the reply. Can you clarify a little, though? Do I put the code you specified in the template before the call for the excerpt? And is the ‘template directory’ supposed to be the name of my WordPress theme? I’m a little confused. Most of my posts have an image first before the text. But I have the images in an ‘assets’ folder. I did not use the wysiwyg editor in the admin panel to insert them into the post. Does that make sense? Not sure if that makes a difference of where and how it would find and pull that first image.
    Thanks again for your help!

    Just leave ‘template directory’ as it is, thats a standard reference to your theme, you dont need to edit it.

    it shouldnt matter if the images are in an assetts folder,
    i tested by instertng an image through the html editor stored in an assetts folder, like

    themename/images/assetts/myimage.jpg

    as long as the image is in the post it should still be found.

    this what i used to show the first image if no feature image was set up, im also using tim thumb to create a thumbnail, but ignore that bit if not needed, you should be able to see i’ve placed the call to ‘catch_that_image’ in a div just before the excerpt, athough you could put it any where in the loop

    <div class="thumbTest">
            <?php if ( has_post_thumbnail() ) {
    			the_post_thumbnail();
    			} else { ?>
    				<img src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo catch_that_image() ?>" alt="" />
    			<?php  } ?>
    
            </div>
    
    					<div class="entry-content">
    						<?php the_excerpt(); ?>
    						<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
    						<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?>
    					</div><!-- .entry-content -->
                        <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
    				</div><!-- #post-## -->

    hope that helps

    Thread Starter djlender

    (@djlender)

    Awesome!! Thanks so much! That worked! Just have to adjust my CSS settings to make it all look pretty. I very much appreciate your help!

    djlender

    no problem, glad it helped

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘catch_that_image only showing image path’ is closed to new replies.