Devolux 2010* - WordPress resource

May/09

2

Automatic Post Thumb

Description

The plug-in extracts the first image uploaded to a WordPress post by using a simple database query. Please note that the database order of the images is not influenced by the way you order your images in a post. The first image uploaded will remain the thumbnail, even if you place it at the end of your article. If you delete the first image, the second one will take its position. If no image at all is added to a post, the plug-in delivers a default image (a white WordPress logo with light grey background).

The title of the thumbnail is generated out of the post title. You can insert the image anywhere in your theme inside the wp-loop by adding a template tag to the source code. Please be aware that the plug-in does not scale or crop the images. It simply delivers the html tag. The styling is intended to be solved via CSS (-> Installation).

Installation

1. Upload “post_thumb” to the /wp-content/plugins/ directory

2. Activate the plugin through the “Plugins” menu in WordPress

3. Place <?php post_thumb(); ?> inside the wp-loop of your template, where ever you want the thumbnail to appear.

4. A nice way to use this plugin is to link the images to the post by wrapping the plugin template tag into the post URL:


<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php post_thumb(); ?></a>

5. Adjust display and image size using CSS. The plugin renounces on resizing the thumbnail because this can be done easily inside your style.css. You can use it at any place of your theme by giving it a max-width value. The height will automatically be adjusted and, in the case that the image is more narrow than the max-width, it will keep its original dimensions.

Download

Automatic Post Thumb plug-in

· ·

4 comments

  • Oluniyi David Ajao · June 21, 2009 at 17:09

    This plugin is one thing I have been looking for. I am giving it a try now.

    Reply

  • Joshua · May 21, 2009 at 18:37

    Good stuff Devolux, thanks for the plugin. It’s nice to be able to extend the functions of the loop. Neo has a point, though- it would be excellent to use the thumbs already created by WP for this job. Good day!

    Reply

  • Admin comment by Devolux · May 11, 2009 at 08:27

    Hi Lee,
    the template tag must be placed inside a wordpress loop. If you want to change the default image, go to the plugin editor of your WP-panel and change the path of “[...]/wp_default.png” to match the location of your own image.

    Reply

  • Lee Down · May 9, 2009 at 18:28

    Love the plugin and ease of use. Styling works like a charm.

    The trouble I’m having at the moment pertains to the default image. You’ve indicated it uses a default wordpress logo, and it’s not appearing on http://goodlifevancouver.com where I’ve applied the code. I’d like to create a default image using her logo, or her favicon image.

    You will see the top post in This Week isn’t displaying anything with only the get_thumb statement. The following posts, showing ‘default image’ are using an if statement. I know it isn’t set up correctly and would love some guidance.

    How am I to name it and where is this image to be placed so the plugin will display it as a default image?

    Reply

Leave a Reply

<< WP-Plugin: jQuery Font Scaling

Custom Text if no tags are available >>