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
This commit is contained in:
Drew Jaynes 2015-10-11 16:54:26 +00:00
parent fb2a4bf9fb
commit 889a89c2a2
2 changed files with 26 additions and 5 deletions

View File

@ -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,

View File

@ -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.