As prior to version 2.9 there was no predefined way to add a post thumbnail, we’ll have to add it as custom information. The easiest way to do this is by adding a custom field.
Custom fields can be added in the editor, a bit under the text area like in the image below:
In this case, we will use the name “Image” (you can give it any name) and for the value the image’s URL (relative URLs are also supported). By default only images from the current domain are displayed. To allow images from different domains, these have to be added as exceptions. This can be done by directly editing the timthumb script and adding a value to the variable
$allowedSites. Just search for it, it’s somewhere at the beginning.
Now that we have out thumbnail declared, we must display it. For this add the following function:
)) : ?>
"<?php echo bloginfo('template_url'); ?>/scripts/timthumb.php?src=<?php echo $thumb; ?>&w=<?php echo $width; ?>&h=<?php echo $height; ?>&zc=1&q=100"
"<?php the_title(); ?>"
"<?php echo $width; ?>"
"<?php echo $height; ?>"
Of course you can call directly the code in the function, I just find it more elegant this way. Now let’s see how we can display a thumbnail if the user hasn’t selected any. The returned value can be used to put the function in an