/ Published in: PHP
Start by creating a default image in Photoshop or Gimp. The size in my example is 200×200 pixels but is of course up to you. Name the image default.gif.
Upload your default.gif image to the image directory in your theme.
Open the index.php file and paste in the following code where you’d like the thumbnails to be displayed:
Save the file.
In each of your posts, create a custom field called post-img. Set its value as the URL of the image you’d like to display as a thumbnail.
Upload your default.gif image to the image directory in your theme.
Open the index.php file and paste in the following code where you’d like the thumbnails to be displayed:
Save the file.
In each of your posts, create a custom field called post-img. Set its value as the URL of the image you’d like to display as a thumbnail.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php $postimageurl = get_post_meta($post->ID, 'post-img', true); if ($postimageurl) { ?> <a href="<?php the_permalink(); ?>" rel="bookmark"><img src="<?php echo $postimageurl; ?>" alt="Post Pic" width="200" height="200" /></a> <?php } else { ?> <a href="<?php the_permalink(); ?>" rel="bookmark"><img src="<?php bloginfo('template_url'); ?>/images/wprecipes.gif" alt="Screenshot" width="200" height="200" /></a> <?php } ?>