Get Post Image is a plugin I recently found that let’s you you place an image from a post into your home page to entice visitors to read your post. I found a trick to OPTIONALLY show an image if it’s found, and not show one if it isn’t. I used the PHP command “strpos” which allows me to search for the default.jpg and not show it if my post doesn’t contain an image.
Installation Instructions:
- Download the plugin from http://www.andrewgrant.org/get-post-image
- Install and activate the plugin as with any other Wordpress installation
- Determine where you want your image thumbnail to appear (usually on your home page as I have done here), and find your post loop (the
<?php
$image_tag = gpi_get_image(0,http://www.site.com/default.jpg, "portfolio-image");
$url = get_permalink();
$pos = strpos($image_tag,"http://www.site.com/default.jpg");
if($pos === false) {
echo "<a href=’$url’ class=preview>$image_tag</a>";
// string needle NOT found in haystack
}
else {
// string needle found in haystack
}
?>
<?php the_excerpt(‘Read the rest of this entry »’); ?>
If you need more help with installing/configuring this plugin, let me know. Just shoot me an email if you like.
I love what I do: 