Changeset 38949 for trunk/src/wp-includes/media.php
- Timestamp:
- 10/26/2016 07:27:51 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/media.php
r38812 r38949 184 184 */ 185 185 function image_downsize( $id, $size = 'medium' ) { 186 187 if ( !wp_attachment_is_image($id) ) 188 return false; 186 $is_image = wp_attachment_is_image( $id ); 189 187 190 188 /** … … 210 208 $is_intermediate = false; 211 209 $img_url_basename = wp_basename($img_url); 210 211 // If the file isn't an image, attempt to replace its URL with a rendered image from its meta. 212 // Otherwise, a non-image type could be returned. 213 if ( ! $is_image ) { 214 if ( ! empty( $meta['sizes'] ) ) { 215 $img_url = str_replace( $img_url_basename, $meta['sizes']['full']['file'], $img_url ); 216 $img_url_basename = $meta['sizes']['full']['file']; 217 $width = $meta['sizes']['full']['width']; 218 $height = $meta['sizes']['full']['height']; 219 } else { 220 return false; 221 } 222 } 212 223 213 224 // try for a new style intermediate size … … 685 696 if ( is_array( $size ) ) { 686 697 $candidates = array(); 698 699 if ( ! isset( $imagedata['file'] ) && isset( $imagedata['sizes']['full'] ) ) { 700 $imagedata['height'] = $imagedata['sizes']['full']['height']; 701 $imagedata['width'] = $imagedata['sizes']['full']['width']; 702 } 687 703 688 704 foreach ( $imagedata['sizes'] as $_size => $data ) { … … 739 755 740 756 // include the full filesystem path of the intermediate file 741 if ( empty( $data['path']) && !empty($data['file']) ) {757 if ( empty( $data['path'] ) && ! empty( $data['file'] ) && ! empty( $imagedata['file'] ) ) { 742 758 $file_url = wp_get_attachment_url($post_id); 743 759 $data['path'] = path_join( dirname($imagedata['file']), $data['file'] ); … … 3124 3140 $response['nonces']['delete'] = wp_create_nonce( 'delete-post_' . $attachment->ID ); 3125 3141 3126 if ( $meta && 'image' === $type) {3142 if ( $meta && ! empty( $meta['sizes'] ) ) { 3127 3143 $sizes = array(); 3128 3144 … … 3172 3188 } 3173 3189 3174 $sizes['full'] = array( 'url' => $attachment_url ); 3175 3176 if ( isset( $meta['height'], $meta['width'] ) ) { 3177 $sizes['full']['height'] = $meta['height']; 3178 $sizes['full']['width'] = $meta['width']; 3179 $sizes['full']['orientation'] = $meta['height'] > $meta['width'] ? 'portrait' : 'landscape'; 3180 } 3181 3182 $response = array_merge( $response, array( 'sizes' => $sizes ), $sizes['full'] ); 3183 } elseif ( $meta && 'video' === $type ) { 3190 if ( 'image' === $type ) { 3191 $sizes['full'] = array( 'url' => $attachment_url ); 3192 3193 if ( isset( $meta['height'], $meta['width'] ) ) { 3194 $sizes['full']['height'] = $meta['height']; 3195 $sizes['full']['width'] = $meta['width']; 3196 $sizes['full']['orientation'] = $meta['height'] > $meta['width'] ? 'portrait' : 'landscape'; 3197 } 3198 3199 $response = array_merge( $response, $sizes['full'] ); 3200 } elseif ( $meta['sizes']['full']['file'] ) { 3201 $sizes['full'] = array( 3202 'url' => $base_url . $meta['sizes']['full']['file'], 3203 'height' => $meta['sizes']['full']['height'], 3204 'width' => $meta['sizes']['full']['width'], 3205 'orientation' => $meta['sizes']['full']['height'] > $meta['sizes']['full']['width'] ? 'portrait' : 'landscape' 3206 ); 3207 } 3208 3209 $response = array_merge( $response, array( 'sizes' => $sizes ) ); 3210 } 3211 3212 if ( $meta && 'video' === $type ) { 3184 3213 if ( isset( $meta['width'] ) ) 3185 3214 $response['width'] = (int) $meta['width'];
Note: See TracChangeset
for help on using the changeset viewer.