WordPress.org

Make WordPress Core

Ticket #34981: 34981.4.diff

File 34981.4.diff, 1.6 KB (added by joemcgill, 3 years ago)
  • src/wp-includes/media.php

    diff --git src/wp-includes/media.php src/wp-includes/media.php
    index f6c5f0f..8a95ea0 100644
    function wp_prepare_attachment_for_js( $attachment ) { 
    31403140                // If the filter does not return something, then image_downsize() is just an expensive
    31413141                // way to check the image metadata, which we do second.
    31423142                foreach ( $possible_sizes as $size => $label ) {
    3143 
    31443143                        /** This filter is documented in wp-includes/media.php */
    31453144                        if ( $downsize = apply_filters( 'image_downsize', false, $attachment->ID, $size ) ) {
    31463145                                if ( ! $downsize[3] )
    function wp_prepare_attachment_for_js( $attachment ) { 
    31513150                                        'url'         => $downsize[0],
    31523151                                        'orientation' => $downsize[2] > $downsize[1] ? 'portrait' : 'landscape',
    31533152                                );
    3154                         } elseif ( isset( $meta['sizes'][ $size ] ) ) {
     3153                        }
     3154                }
     3155
     3156                // If the image_downsize filter didn't return anything, we use the metadata.
     3157                if ( empty( $sizes ) && isset( $meta['sizes'] ) ) {
     3158                        foreach( $meta['sizes'] as $size => $size_meta ) {
    31553159                                if ( ! isset( $base_url ) )
    31563160                                        $base_url = str_replace( wp_basename( $attachment_url ), '', $attachment_url );
    31573161
    3158                                 // Nothing from the filter, so consult image metadata if we have it.
    3159                                 $size_meta = $meta['sizes'][ $size ];
    3160 
    31613162                                // We have the actual image size, but might need to further constrain it if content_width is narrower.
    31623163                                // Thumbnail, medium, and full sizes are also checked against the site's height/width options.
    31633164                                list( $width, $height ) = image_constrain_size_for_editor( $size_meta['width'], $size_meta['height'], $size, 'edit' );