WordPress.org

Make WordPress Core

Changeset 35022


Ignore:
Timestamp:
10/11/2015 04:53:35 PM (4 years ago)
Author:
DrewAPicture
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/post.php

    r34925 r35022  
    13971397        $old_content_width = $content_width;
    13981398        $content_width = 266;
    1399         if ( !isset( $_wp_additional_image_sizes['post-thumbnail'] ) )
    1400             $thumbnail_html = wp_get_attachment_image( $thumbnail_id, array( $content_width, $content_width ) );
    1401         else
    1402             $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-thumbnail' );
     1399
     1400        $size = isset( $_wp_additional_image_sizes['post-thumbnail'] ) ? 'post-thumbnail' : array( $content_width, $content_width );
     1401
     1402        /**
     1403         * Filter the size used to display the post thumbnail image in the 'Featured Image' meta box.
     1404         *
     1405         * Note: When a theme adds 'post-thumbnail' support, a special 'post-thumbnail'
     1406         * image size is registered, which differs from the 'thumbnail' image size
     1407         * managed via the Settings > Media screen. See the `$size` parameter description
     1408         * for more information on default values.
     1409         *
     1410         * @since 4.4.0
     1411         *
     1412         * @param string|array $size         Post thumbnail image size to display in the meta box. Accepts
     1413         *                                   any valid image size, or an array of height and width values.
     1414         *                                   If the 'post-thumbnail' size is set, default is 'post-thumbnail'.
     1415         *                                   Otherwise, default is an array with `$content_width` as the
     1416         *                                   height and width values.
     1417         * @param int          $thumbnail_id Post thumbnail attachment ID.
     1418         * @param WP_Post      $post         The post object associated with the thumbnail.
     1419         */
     1420        $size = apply_filters( 'admin_post_thumbnail_size', $size, $thumbnail_id, $post );
     1421
     1422        $thumbnail_html = wp_get_attachment_image( $thumbnail_id, $size );
     1423
    14031424        if ( !empty( $thumbnail_html ) ) {
    14041425            $ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $post->ID );
Note: See TracChangeset for help on using the changeset viewer.