Media: Introduce the admin_post_thumbnail_size
filter, which enables manipulation of the image size used to display the post thumbnail in the 'Featured Image' meta box.
This filter has no effect on the image size used to display post thumbnails on the front-end. Props dboulet, DrewAPicture. Fixes #28512. git-svn-id: https://develop.svn.wordpress.org/trunk@35022 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
bf0fa3a570
commit
4d98b99cc3
@ -1396,10 +1396,31 @@ function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) {
|
||||
if ( $thumbnail_id && get_post( $thumbnail_id ) ) {
|
||||
$old_content_width = $content_width;
|
||||
$content_width = 266;
|
||||
if ( !isset( $_wp_additional_image_sizes['post-thumbnail'] ) )
|
||||
$thumbnail_html = wp_get_attachment_image( $thumbnail_id, array( $content_width, $content_width ) );
|
||||
else
|
||||
$thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-thumbnail' );
|
||||
|
||||
$size = isset( $_wp_additional_image_sizes['post-thumbnail'] ) ? 'post-thumbnail' : array( $content_width, $content_width );
|
||||
|
||||
/**
|
||||
* Filter the size used to display the post thumbnail image in the 'Featured Image' meta box.
|
||||
*
|
||||
* Note: When a theme adds 'post-thumbnail' support, a special 'post-thumbnail'
|
||||
* image size is registered, which differs from the 'thumbnail' image size
|
||||
* managed via the Settings > Media screen. See the `$size` parameter description
|
||||
* for more information on default values.
|
||||
*
|
||||
* @since 4.4.0
|
||||
*
|
||||
* @param string|array $size Post thumbnail image size to display in the meta box. Accepts
|
||||
* any valid image size, or an array of height and width values.
|
||||
* If the 'post-thumbnail' size is set, default is 'post-thumbnail'.
|
||||
* Otherwise, default is an array with `$content_width` as the
|
||||
* height and width values.
|
||||
* @param int $thumbnail_id Post thumbnail attachment ID.
|
||||
* @param WP_Post $post The post object associated with the thumbnail.
|
||||
*/
|
||||
$size = apply_filters( 'admin_post_thumbnail_size', $size, $thumbnail_id, $post );
|
||||
|
||||
$thumbnail_html = wp_get_attachment_image( $thumbnail_id, $size );
|
||||
|
||||
if ( !empty( $thumbnail_html ) ) {
|
||||
$ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $post->ID );
|
||||
$content = sprintf( $set_thumbnail_link,
|
||||
|
Loading…
Reference in New Issue
Block a user