From efb191c2edd06f720ef1b0fad3a170dfe112fec6 Mon Sep 17 00:00:00 2001 From: Joe McGill Date: Fri, 16 Dec 2016 20:30:42 +0000 Subject: [PATCH] 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. Props gitlost. Fixes #39231. See #38594. Built from https://develop.svn.wordpress.org/trunk@39617 git-svn-id: http://core.svn.wordpress.org/trunk@39557 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/image.php | 24 +++++++++++++++++++----- wp-includes/version.php | 2 +- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php index 5f7b583d5d..4ae53b9c3a 100644 --- a/wp-admin/includes/image.php +++ b/wp-admin/includes/image.php @@ -221,14 +221,28 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) { $fallback_sizes = apply_filters( 'fallback_intermediate_image_sizes', $fallback_sizes, $metadata ); $sizes = array(); + $_wp_additional_image_sizes = wp_get_additional_image_sizes(); foreach ( $fallback_sizes as $s ) { - $sizes[ $s ]['width'] = get_option( "{$s}_size_w" ); - $sizes[ $s ]['height'] = get_option( "{$s}_size_h" ); + if ( isset( $_wp_additional_image_sizes[ $s ]['width'] ) ) { + $sizes[ $s ]['width'] = intval( $_wp_additional_image_sizes[ $s ]['width'] ); + } else { + $sizes[ $s ]['width'] = get_option( "{$s}_size_w" ); + } - // Force thumbnails to be soft crops. - if ( ! 'thumbnail' === $s ) { - $sizes[ $s ]['crop'] = get_option( "{$s}_crop" ); + if ( isset( $_wp_additional_image_sizes[ $s ]['height'] ) ) { + $sizes[ $s ]['height'] = intval( $_wp_additional_image_sizes[ $s ]['height'] ); + } else { + $sizes[ $s ]['height'] = get_option( "{$s}_size_h" ); + } + + if ( isset( $_wp_additional_image_sizes[ $s ]['crop'] ) ) { + $sizes[ $s ]['crop'] = $_wp_additional_image_sizes[ $s ]['crop']; + } else { + // Force thumbnails to be soft crops. + if ( ! 'thumbnail' === $s ) { + $sizes[ $s ]['crop'] = get_option( "{$s}_crop" ); + } } } diff --git a/wp-includes/version.php b/wp-includes/version.php index 988da4434b..0859fe830a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.8-alpha-39616'; +$wp_version = '4.8-alpha-39617'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.