Ticket #37699: 37699-images.diff
File 37699-images.diff, 7.2 KB (added by , 9 years ago) |
---|
-
src/wp-admin/includes/image-edit.php
700 700 * Saves image to post along with enqueued changes 701 701 * in $_REQUEST['history'] 702 702 * 703 * @global array $_wp_additional_image_sizes704 *705 703 * @param int $post_id 706 704 * @return \stdClass 707 705 */ 708 706 function wp_save_image( $post_id ) { 709 global $_wp_additional_image_sizes;707 $_wp_additional_image_sizes = wp_get_additional_image_sizes(); 710 708 711 709 $return = new stdClass; 712 710 $success = $delete = $scaled = $nocrop = false; -
src/wp-admin/includes/image.php
67 67 * 68 68 * @since 2.1.0 69 69 * 70 * @global array $_wp_additional_image_sizes71 *72 70 * @param int $attachment_id Attachment Id to process. 73 71 * @param string $file Filepath of the Attached image. 74 72 * @return mixed Metadata for attachment. … … 87 85 $metadata['file'] = _wp_relative_upload_path($file); 88 86 89 87 // Make thumbnails and other intermediate sizes. 90 global $_wp_additional_image_sizes;88 $_wp_additional_image_sizes = wp_get_additional_image_sizes(); 91 89 92 90 $sizes = array(); 93 91 foreach ( get_intermediate_image_sizes() as $s ) { 94 92 $sizes[$s] = array( 'width' => '', 'height' => '', 'crop' => false ); 95 if ( isset( $_wp_additional_image_sizes[$s]['width'] ) ) 96 $sizes[$s]['width'] = intval( $_wp_additional_image_sizes[$s]['width'] ); // For theme-added sizes 97 else 98 $sizes[$s]['width'] = get_option( "{$s}_size_w" ); // For default sizes set in options 99 if ( isset( $_wp_additional_image_sizes[$s]['height'] ) ) 100 $sizes[$s]['height'] = intval( $_wp_additional_image_sizes[$s]['height'] ); // For theme-added sizes 101 else 102 $sizes[$s]['height'] = get_option( "{$s}_size_h" ); // For default sizes set in options 103 if ( isset( $_wp_additional_image_sizes[$s]['crop'] ) ) 104 $sizes[$s]['crop'] = $_wp_additional_image_sizes[$s]['crop']; // For theme-added sizes 105 else 106 $sizes[$s]['crop'] = get_option( "{$s}_crop" ); // For default sizes set in options 93 if ( isset( $_wp_additional_image_sizes[$s]['width'] ) ) { 94 // For theme-added sizes 95 $sizes[$s]['width'] = intval( $_wp_additional_image_sizes[$s]['width'] ); 96 } else { 97 // For default sizes set in options 98 $sizes[$s]['width'] = get_option( "{$s}_size_w" ); 99 } 100 101 if ( isset( $_wp_additional_image_sizes[$s]['height'] ) ) { 102 // For theme-added sizes 103 $sizes[$s]['height'] = intval( $_wp_additional_image_sizes[$s]['height'] ); 104 } else { 105 // For default sizes set in options 106 $sizes[$s]['height'] = get_option( "{$s}_size_h" ); 107 } 108 109 if ( isset( $_wp_additional_image_sizes[$s]['crop'] ) ) { 110 // For theme-added sizes 111 $sizes[$s]['crop'] = $_wp_additional_image_sizes[$s]['crop']; 112 } else { 113 // For default sizes set in options 114 $sizes[$s]['crop'] = get_option( "{$s}_crop" ); 115 } 107 116 } 108 117 109 118 /** -
src/wp-admin/includes/post.php
1367 1367 * 1368 1368 * @since 2.9.0 1369 1369 * 1370 * @global array $_wp_additional_image_sizes1371 *1372 1370 * @param int $thumbnail_id ID of the attachment used for thumbnail 1373 1371 * @param mixed $post The post ID or object associated with the thumbnail, defaults to global $post. 1374 1372 * @return string html 1375 1373 */ 1376 1374 function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) { 1377 global $_wp_additional_image_sizes;1375 $_wp_additional_image_sizes = wp_get_additional_image_sizes(); 1378 1376 1379 1377 $post = get_post( $post ); 1380 1378 $post_type_object = get_post_type_object( $post->post_type ); -
src/wp-includes/media.php
7 7 */ 8 8 9 9 /** 10 * Retrieve additional image sizes. 11 * 12 * @since 4.7.0 13 * 14 * @global array $_wp_additional_image_sizes 15 */ 16 function wp_get_additional_image_sizes() { 17 global $_wp_additional_image_sizes; 18 if ( ! $_wp_additional_image_sizes ) { 19 $_wp_additional_image_sizes = array(); 20 } 21 return $_wp_additional_image_sizes; 22 } 23 24 /** 10 25 * Scale down the default size of an image. 11 26 * 12 27 * This is so that the image is a better fit for the editor and theme. … … 27 42 * @since 2.5.0 28 43 * 29 44 * @global int $content_width 30 * @global array $_wp_additional_image_sizes31 45 * 32 46 * @param int $width Width of the image in pixels. 33 47 * @param int $height Height of the image in pixels. … … 39 53 * @return array Width and height of what the result image should resize to. 40 54 */ 41 55 function image_constrain_size_for_editor( $width, $height, $size = 'medium', $context = null ) { 42 global $content_width , $_wp_additional_image_sizes;56 global $content_width; 43 57 58 $_wp_additional_image_sizes = wp_get_additional_image_sizes(); 59 44 60 if ( ! $context ) 45 61 $context = is_admin() ? 'edit' : 'display'; 46 62 … … 82 98 if ( intval($content_width) > 0 ) { 83 99 $max_width = min( intval($content_width), $max_width ); 84 100 } 85 } elseif ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) && in_array( $size, array_keys( $_wp_additional_image_sizes ) ) ) {101 } elseif ( ! empty( $_wp_additional_image_sizes ) && in_array( $size, array_keys( $_wp_additional_image_sizes ) ) ) { 86 102 $max_width = intval( $_wp_additional_image_sizes[$size]['width'] ); 87 103 $max_height = intval( $_wp_additional_image_sizes[$size]['height'] ); 88 if ( intval($content_width) > 0 && 'edit' == $context ) // Only in admin. Assume that theme authors know what they're doing. 89 $max_width = min( intval($content_width), $max_width ); 104 // Only in admin. Assume that theme authors know what they're doing. 105 if ( intval( $content_width ) > 0 && 'edit' === $context ) { 106 $max_width = min( intval( $content_width ), $max_width ); 107 } 90 108 } 91 109 // $size == 'full' has no constraint 92 110 else { … … 258 276 * 259 277 * @since 3.9.0 260 278 * 261 * @global array $_wp_additional_image_sizes262 *263 279 * @param string $name The image size to check. 264 280 * @return bool True if the image size exists, false if not. 265 281 */ 266 282 function has_image_size( $name ) { 267 global $_wp_additional_image_sizes; 268 269 return isset( $_wp_additional_image_sizes[ $name ] ); 283 $sizes = wp_get_additional_image_sizes(); 284 return isset( $sizes[ $name ] ); 270 285 } 271 286 272 287 /** … … 748 763 * 749 764 * @since 3.0.0 750 765 * 751 * @global array $_wp_additional_image_sizes752 *753 766 * @return array Returns a filtered array of image size strings. 754 767 */ 755 768 function get_intermediate_image_sizes() { 756 global $_wp_additional_image_sizes;769 $_wp_additional_image_sizes = wp_get_additional_image_sizes(); 757 770 $image_sizes = array('thumbnail', 'medium', 'medium_large', 'large'); // Standard sizes 758 if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) )771 if ( ! empty( $_wp_additional_image_sizes ) ) { 759 772 $image_sizes = array_merge( $image_sizes, array_keys( $_wp_additional_image_sizes ) ); 773 } 760 774 761 775 /** 762 776 * Filters the list of intermediate image sizes.