mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-02-21 16:22:44 +00:00
Media: Use featured image if available for attachment as preview instead of icon.
When rendering a list of attachments in `WP_Media_List_Table` class, none image attachments, show a generic icon. However, attachment types like audio and video support adding a featured image. For attachments that have featured images, us this image instead of the icon. This featured image is a better preview than a generic icon. Props spacedmonkey, samful, johnbillion, JavierCasares, seanchayes, antpb, cadic, JeffPaul. Fixes #49852. git-svn-id: https://develop.svn.wordpress.org/trunk@54941 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
08dfd2b550
commit
ed6fa5c090
@ -110,8 +110,10 @@ class WP_Media_List_Table extends WP_List_Table {
|
||||
'per_page' => $wp_query->query_vars['posts_per_page'],
|
||||
)
|
||||
);
|
||||
|
||||
update_post_parent_caches( $wp_query->posts );
|
||||
if ( $wp_query->posts ) {
|
||||
update_post_thumbnail_cache( $wp_query );
|
||||
update_post_parent_caches( $wp_query->posts );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -424,8 +426,18 @@ class WP_Media_List_Table extends WP_List_Table {
|
||||
public function column_title( $post ) {
|
||||
list( $mime ) = explode( '/', $post->post_mime_type );
|
||||
|
||||
$attachment_id = $post->ID;
|
||||
|
||||
if ( has_post_thumbnail( $post ) ) {
|
||||
$thumbnail_id = get_post_thumbnail_id( $post );
|
||||
|
||||
if ( ! empty( $thumbnail_id ) ) {
|
||||
$attachment_id = $thumbnail_id;
|
||||
}
|
||||
}
|
||||
|
||||
$title = _draft_or_post_title();
|
||||
$thumb = wp_get_attachment_image( $post->ID, array( 60, 60 ), true, array( 'alt' => '' ) );
|
||||
$thumb = wp_get_attachment_image( $attachment_id, array( 60, 60 ), true, array( 'alt' => '' ) );
|
||||
$link_start = '';
|
||||
$link_end = '';
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user