/* Featured Image Column All Posts List */
add_filter('manage_post_posts_columns', 'misha_featured_image_column');
function misha_featured_image_column( $column_array ) {
$column_array = array_slice( $column_array, 0, 1, true )
+ array('featured_image' => 'Featured Image')
+ array_slice( $column_array, 1, NULL, true );
return $column_array;
}
add_action('manage_posts_custom_column', 'misha_render_the_column', 10, 2);
function misha_render_the_column( $column_name, $post_id ) {
if( $column_name == 'featured_image' ) {
if( has_post_thumbnail( $post_id ) ) {
$thumb_id = get_post_thumbnail_id( $post_id );
echo '<img data-id="' . $thumb_id . '" src="' . wp_get_attachment_url( $thumb_id ) . '" />';
} else {
echo '<img data-id="-1" src="' . get_stylesheet_directory_uri() . '/placeholder.png" />';
}}}
add_action( 'admin_head', 'misha_custom_css' );
function misha_custom_css(){
echo '<style>
#featured_image{
width:100px;
}
td.featured_image.column-featured_image img{
max-width: 100%;
height: auto;
}
#misha_featured_image .title{margin-top:10px;display:block;}
#misha_featured_image a.misha_upload_featured_image{
display:inline-block;
margin:10px 0 0;
}
#misha_featured_image img{
display:block;
max-width:200px !important;
height:auto;
}
#misha_featured_image .misha_remove_featured_image{
display:none;
}
</style>';
}
Source: Rudrastyh
How do you know whether a Post has a Featured Image or not? The answer is simple. Just add a Featured Image Column in All Posts list. The above code adds a featured image thumbnail to the all posts list, making it easy for publishers.
Add the above code to your Child Theme’s functions.php. This generates a ‘Featured Image‘ column in the admin all posts list.