WordPress 4.7.1
[autoinstalls/wordpress.git] / wp-admin / includes / image.php
index 5f7b583d5d0481ea260f0b1bf3afbb8c037cd78d..4ae53b9c3a98c44003be4a714ef06ac94ef526ab 100644 (file)
@@ -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" );
+                       }
+
+                       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" );
+                       }
 
-                       // Force thumbnails to be soft crops.
-                       if ( ! 'thumbnail' === $s ) {
-                               $sizes[ $s ]['crop'] = get_option( "{$s}_crop" );
+                       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" );
+                               }
                        }
                }