Adds multiple post thumbnails to a post type. If you've ever wanted more than one Featured Image on a post, this plugin is for you.
This is caused by using the example in previous readmes that didn't do a check for the MultiPostThumbnails class existing first. This has been corrected in the Installation section.
You can loop through an array of the post types:
if (class_exists('MultiPostThumbnails')) {
$types = array('post', 'page', 'my_post_type');
foreach($types as $type) {
$thumb = new MultiPostThumbnails(array(
'label' => 'Secondary Image',
'id' => 'secondary-image',
'post_type' => $type
)
);
}
}
After you have registered a new post thumbnail, register a new image size for it. e.g if your post thumbnail id is secondary-image and it is for a post, it probably makes sense to use something like:
add_image_size('post-secondary-image-thumbnail', 250, 150);
This will register a new image size of 250x150 px. Then, when you display the thumbnail in your theme, update the call to MultiPostThumbnails::the_post_thumbnail() to pass in the image size:
MultiPostThumbnails::the_post_thumbnail('post', 'secondary-image', NULL, 'post-secondary-image-thumbnail');
You can register multiple image sizes for a given thumbnail if desired.
Requires: 2.9.2 or higher
Compatible up to: 3.2.1
Last Updated: 2011-11-10
Downloads: 23,285
Got something to say? Need help?