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. Built from https://develop.svn.wordpress.org/trunk@54941 git-svn-id: http://core.svn.wordpress.org/trunk@54493 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
aec68c417e
commit
a5ed225499
|
@ -110,8 +110,10 @@ class WP_Media_List_Table extends WP_List_Table {
|
||||||
'per_page' => $wp_query->query_vars['posts_per_page'],
|
'per_page' => $wp_query->query_vars['posts_per_page'],
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
if ( $wp_query->posts ) {
|
||||||
update_post_parent_caches( $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 ) {
|
public function column_title( $post ) {
|
||||||
list( $mime ) = explode( '/', $post->post_mime_type );
|
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();
|
$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_start = '';
|
||||||
$link_end = '';
|
$link_end = '';
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.2-alpha-54940';
|
$wp_version = '6.2-alpha-54941';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue