**Auto Post Thumbnail**
„http://wordpress.org/plugins/auto-post-thumbnail/“:http://wordpress.org/plugins/auto-post-thumbnail/
Automatically generate the Post Thumbnail (Featured Thumbnail) from the first image in post or any custom post type only if Post Thumbnail is not set.
If the post thumbnail is already present, the plugin will do nothing. If you don’t want a post thumbnail for some post with images, just add a custom field skip_post_thumb to the post and the plugin will restrain itself from generating post thumbnail. The plugin also provides a Batch Processing capability to generate post thumbnails for already published posts.
**Další pluginy**
„http://beginnersbook.com/2013/09/set-default-thumbnail-featured-fallback-image-wordpress-automatically/“:http://beginnersbook.com/2013/09/set-default-thumbnail-featured-fallback-image-wordpress-automatically/
„http://wpfreesetup.com/fix-featured-image-issues-wordpress-plugins/“:http://wpfreesetup.com/fix-featured-image-issues-wordpress-plugins/
*nebo pomocí funkcí:*
/—code php
ID);
if (!$already_has_thumb) {
$attached_image = get_children( „post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1“ );
if ($attached_image) {
foreach ($attached_image as $attachment_id => $attachment) {
set_post_thumbnail($post->ID, $attachment_id);
}
}
}
}
add_action(‚the_post‘, ‚autoset_featured‘);
add_action(‚save_post‘, ‚autoset_featured‘);
add_action(‚draft_to_publish‘, ‚autoset_featured‘);
add_action(‚new_to_publish‘, ‚autoset_featured‘);
add_action(‚pending_to_publish‘, ‚autoset_featured‘);
add_action(‚future_to_publish‘, ‚autoset_featured‘);
?>
\—
*alternativně*
/—code php
function set_first_as_featured($attachment_ID){
$post_ID = get_post($attachment_ID)->post_parent;
if(!has_post_thumbnail($post_ID)){
set_post_thumbnail($post_ID, $attachment_ID);
}
}
add_action(‚add_attachment‘, ‚set_first_as_featured‘);
add_action(‚edit_attachment‘, ‚set_first_as_featured‘);
\—
On every upload / edit attachment, function checks if the post already has featured image. If it has not, image in question is set as featured. Every next picture will be ignored (since post already has featured image).
*případně*
/—code php
wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), ‚thumbnail‘ )[0];
\—
„Get The First Image From a Post »“:http://css-tricks.com/snippets/wordpress/get-the-first-image-from-a-post/