The new the_post_image functionality in WordPress version 2.9 has been enhanced.
New is the wp-settings.php line
// Load in support for template functions which the theme supports
require_if_theme_supports( 'post-thumbnails', ABSPATH . WPINC . '/post-image-template.php' );
In functions.php it queries whether the theme supports post-thumbnail function:
if ( function_exists( 'add_theme_support' ) )
add_theme_support( 'post-thumbnails' );
If you look at the file wp-includes/post-image-template.php, there are 4 new features:
- has_post_image()
- get_post_image_id()
- the_post_image()
- get_the_post_image()
The theme itself can check within the loop, if the post has a Post-Thumbnail, and if so, then it can be output:
'alignleft' ) ); ?>
Those interested in more features and information should check the file in WordPress 2.9: wp-includes/post-image-template.php
Especially the function: get_the_post_image
It allows to adjust the output by using hooks.
In get_the_post_image
the function wp_get_attachment_image
get also used, what has been explained in detail in this post just a few days ago.
Comments
4 responses to “WordPress 2.9 add_theme_support and has_post_image”
Nice feature. Can’t wait to start using it.
[…] provedete jednoduše vložením funkce (a otestováním její existence) add_theme_support v souboru šablony […]
I’ve made a plugin (an update) related to this topic. I would like to share with you and get your opinion since it’s unique and ready for WP 2.9. Please send me an email (and delete, eventualy this comment).
Just a heads up for anyone reading this:
has_post_image() and the_post_image()
are now:
has_post_thumbnail() and the_post_thumbnail()
Make sure you change those function names before upgrading or your site will break.