Make WordPress Core


Ignore:
Timestamp:
12/21/2016 05:52:54 AM (10 years ago)
Author:
pento
Message:

Media: Allow PDF fallbacks filter to process custom sizes.

This fixes an oversight in [39246], which added a hook for filtering the array of sizes used for PDF thumbnails, but failed to provide a way for sizes added through add_image_size() to be processed.

Merge of [39617] to the 4.7 branch.

Props gitlost.
Fixes #39231. See #38594.

Location:
branches/4.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/src/wp-admin/includes/image.php

    r39246 r39633  
    222222
    223223                $sizes = array();
     224                $_wp_additional_image_sizes = wp_get_additional_image_sizes();
    224225
    225226                foreach ( $fallback_sizes as $s ) {
    226                         $sizes[ $s ]['width']  = get_option( "{$s}_size_w" );
    227                         $sizes[ $s ]['height'] = get_option( "{$s}_size_h" );
    228 
    229                         // Force thumbnails to be soft crops.
    230                         if ( ! 'thumbnail' === $s ) {
    231                                 $sizes[ $s ]['crop'] = get_option( "{$s}_crop" );
     227                        if ( isset( $_wp_additional_image_sizes[ $s ]['width'] ) ) {
     228                                $sizes[ $s ]['width'] = intval( $_wp_additional_image_sizes[ $s ]['width'] );
     229                        } else {
     230                                $sizes[ $s ]['width'] = get_option( "{$s}_size_w" );
     231                        }
     232
     233                        if ( isset( $_wp_additional_image_sizes[ $s ]['height'] ) ) {
     234                                $sizes[ $s ]['height'] = intval( $_wp_additional_image_sizes[ $s ]['height'] );
     235                        } else {
     236                                $sizes[ $s ]['height'] = get_option( "{$s}_size_h" );
     237                        }
     238
     239                        if ( isset( $_wp_additional_image_sizes[ $s ]['crop'] ) ) {
     240                                $sizes[ $s ]['crop'] = $_wp_additional_image_sizes[ $s ]['crop'];
     241                        } else {
     242                                // Force thumbnails to be soft crops.
     243                                if ( ! 'thumbnail' === $s ) {
     244                                        $sizes[ $s ]['crop'] = get_option( "{$s}_crop" );
     245                                }
    232246                        }
    233247                }
Note: See TracChangeset for help on using the changeset viewer.