diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php
index 51c49f83d2..66ffa65e4b 100644
|
a
|
b
|
function wp_prepare_attachment_for_js( $attachment ) { |
| 4281 | 4281 | * to check the image metadata, which we do second. |
| 4282 | 4282 | */ |
| 4283 | 4283 | foreach ( $possible_sizes as $size => $label ) { |
| 4284 | | |
| 4285 | 4284 | /** This filter is documented in wp-includes/media.php */ |
| 4286 | 4285 | $downsize = apply_filters( 'image_downsize', false, $attachment->ID, $size ); |
| 4287 | 4286 | |
| … |
… |
function wp_prepare_attachment_for_js( $attachment ) { |
| 4296 | 4295 | 'url' => $downsize[0], |
| 4297 | 4296 | 'orientation' => $downsize[2] > $downsize[1] ? 'portrait' : 'landscape', |
| 4298 | 4297 | ); |
| 4299 | | } elseif ( isset( $meta['sizes'][ $size ] ) ) { |
| 4300 | | // Nothing from the filter, so consult image metadata if we have it. |
| 4301 | | $size_meta = $meta['sizes'][ $size ]; |
| 4302 | | |
| 4303 | | // We have the actual image size, but might need to further constrain it if content_width is narrower. |
| 4304 | | // Thumbnail, medium, and full sizes are also checked against the site's height/width options. |
| 4305 | | list( $width, $height ) = image_constrain_size_for_editor( $size_meta['width'], $size_meta['height'], $size, 'edit' ); |
| | 4298 | } |
| 4306 | 4299 | |
| 4307 | | $sizes[ $size ] = array( |
| 4308 | | 'height' => $height, |
| 4309 | | 'width' => $width, |
| 4310 | | 'url' => $base_url . $size_meta['file'], |
| 4311 | | 'orientation' => $height > $width ? 'portrait' : 'landscape', |
| 4312 | | ); |
| | 4300 | // If the image_downsize filter did not return anything, use the metadata. |
| | 4301 | if ( empty( $sizes ) && isset( $meta['sizes'] ) ) { |
| | 4302 | foreach ( $meta['sizes'] as $size => $size_meta ) { |
| | 4303 | // We have the actual image size, but might need to further constrain it if content_width is narrower. |
| | 4304 | // Thumbnail, medium, and full sizes are also checked against the site's height/width options. |
| | 4305 | list( $width, $height ) = image_constrain_size_for_editor( $size_meta['width'], $size_meta['height'], $size, 'edit' ); |
| | 4306 | |
| | 4307 | $sizes[ $size ] = array( |
| | 4308 | 'height' => $height, |
| | 4309 | 'width' => $width, |
| | 4310 | 'url' => $base_url . $size_meta['file'], |
| | 4311 | 'orientation' => $height > $width ? 'portrait' : 'landscape', |
| | 4312 | ); |
| | 4313 | } |
| 4313 | 4314 | } |
| 4314 | 4315 | } |
| 4315 | 4316 | |