From 889a89c2a29a19d5f50d7b62c805710bc1c56bd8 Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Sun, 11 Oct 2015 16:54:26 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@35022 git-svn-id: http://core.svn.wordpress.org/trunk@34987 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/post.php | 29 +++++++++++++++++++++++++---- wp-includes/version.php | 2 +- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index 83756e695a..f5f6234994 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -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, diff --git a/wp-includes/version.php b/wp-includes/version.php index 60d541f04c..59e59e31c1 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-35021'; +$wp_version = '4.4-alpha-35022'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.