December 27th, 2009

How to add a thumbnail to a post

Because some users are having a hard time adding a thumbnail to a post using my themes, I have improved the method to add thumbnails and created this tutorial on how to do it:

Previously, WordPress did not have any support for adding content outside the post except for custom fields. Starting version 2.9, a feature that enables users to add thumbnails has been added.

In my themes, I have  added 3 ways of adding a thumbnail to a post. Here they are:

WordPress Thumbnail System

As of version 2.9, WordPress includes a feature that allows users to add thumbnails to their posts, if the theme supports it.

Thumbnails can be added from the WordPress “Edit Post” page, in the section “Post Thumbnail” in the right sidebar (as shown in the screenshot below).

To add a thumbnail, click the link “Set thumbnail”. The media library will appear. In the media library, select the image you want to use as thumbnail by clicking on “Show” and then select “Use as thumbnail”. After updating the post, the thumbnail will appear beside the post’s excerpt. The image will be automatically resized.

Custom fields

Custom fields can be added from the post’s edit page, in the section called Custom Fields.

To  create a new custom field, click the link “Enter new”. Under “Name” write “Image” (or “image”) and under “Value” enter the path to the image excluding the domain name (note that the image must have previously been uploaded to the media gallery).

e.g. “/wp-content/uploads/thumbnail.png”

The size of the image does not matter as the thumbnail generation script automatically crops and resizes the image.

Check the screenshot on the right to see how to add a custom field.

First image in post

If no native thumbnail and no thumbnail custom field has been found for the post, the theme will try to retrieve the first image in the post and display it as a thumbnail. Please note that this does not work if the image is hosted on a different server.

Finally, if no thumbnail has been found and the post contains no images, a larger excerpt will be shown.

Hope this was helpful. Merry Christmas to all and a Happy New Year.

  • Digg
  • Technorati Favorites
  • Twitter
  • Facebook
  • Yahoo Messenger
  • Yahoo Mail
  • Gmail
  • Share/Bookmark

One Response to "How to add a thumbnail to a post"

  1. I have read couple of articles on your blog and could say it was really interesting, thanks for sharing that.

Leave a Reply

Powered by WordPress