WordPress 2.9 Changes the Post Image Function

A change that may break your theme

WordPress

In the latest WordPress version, there has been a change in how post images are handled. As of V2.9, the_post_image() has been replaced with the_post_thumbnail(). That’s right, replaced, not in addition to. The new function has some interesting features as well.

Defining Thumbnail Sizes

Set both max sizes in the function like this:
the_post_thumbnail(array(100,150));
This defines the thumbnail as 100px wide max or 150px high max. Maintains aspect ratio.

Set a style class

Set a style class in the function like this:
the_post_thumbnail(array(100,150), array('class' => 'alignleft'));
or add your own class like this:
the_post_thumbnail(array(100,150), array('class' => 'alignleft custom_class'));

Typical usage

In the loop, add the post thumbnail along with the excerpt:
while (have_posts()) : the_post();
the_post_thumbnail(array(100,100), array('class' => 'alignleft'));
the_excerpt();
endwhile;

Enable it in your theme function file

Another quirk that’s significant is this function isn’t enabled by default. It has to be enabled in your theme function file. To make these new functions work, add this to functions.php:
add_theme_support( 'post-thumbnails' );
Without this line the post thumbnails functions won’t work.

Add a Post Thumbnail

With V2.9 there is now a place to add a post thumbnail. The thumbnail is not drawn from the content of the post, it stands alone. If a thumbnail isn’t chosen, the_post_thumbnail() function won’t render a thumbnail.

Conclusion

Much more control over thumbnails in V2.9, but there’s a chance this new function may break your existing theme or a plugin. More control over what is used as a thumbnail, but you have to define the thumbnail. Test carefully

Posts By:

Web Design, Development and Consulting WordPress Themes, Plugins and Custom Coding
Share 'WordPress 2.9 Changes the Post Image Function' on AddThis Share 'WordPress 2.9 Changes the Post Image Function' on AddToAny Share 'WordPress 2.9 Changes the Post Image Function' on Blogger Share 'WordPress 2.9 Changes the Post Image Function' on Bloglines Share 'WordPress 2.9 Changes the Post Image Function' on Current Share 'WordPress 2.9 Changes the Post Image Function' on Evernote Share 'WordPress 2.9 Changes the Post Image Function' on Google Buzz Share 'WordPress 2.9 Changes the Post Image Function' on TechNet Share 'WordPress 2.9 Changes the Post Image Function' on Technorati Share 'WordPress 2.9 Changes the Post Image Function' on Yahoo! Bookmarks Share 'WordPress 2.9 Changes the Post Image Function' on Email Share 'WordPress 2.9 Changes the Post Image Function' on Gmail

Comments are closed.