Changeset 38303
- Timestamp:
- 08/22/2016 04:36:42 AM (8 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/image-edit.php
r38294 r38303 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; -
trunk/src/wp-admin/includes/image.php
r37488 r38303 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. … … 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 -
trunk/src/wp-admin/includes/post.php
r38272 r38303 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. … … 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 ); -
trunk/src/wp-includes/media.php
r38296 r38303 6 6 * @subpackage Media 7 7 */ 8 9 /** 10 * Retrieve additional image sizes. 11 * 12 * @since 4.7.0 13 * 14 * @global array $_wp_additional_image_sizes 15 * 16 * @return array Additional images size data. 17 */ 18 function wp_get_additional_image_sizes() { 19 global $_wp_additional_image_sizes; 20 if ( ! $_wp_additional_image_sizes ) { 21 $_wp_additional_image_sizes = array(); 22 } 23 return $_wp_additional_image_sizes; 24 } 8 25 9 26 /** … … 28 45 * 29 46 * @global int $content_width 30 * @global array $_wp_additional_image_sizes31 47 * 32 48 * @param int $width Width of the image in pixels. … … 40 56 */ 41 57 function image_constrain_size_for_editor( $width, $height, $size = 'medium', $context = null ) { 42 global $content_width, $_wp_additional_image_sizes; 58 global $content_width; 59 60 $_wp_additional_image_sizes = wp_get_additional_image_sizes(); 43 61 44 62 if ( ! $context ) … … 83 101 $max_width = min( intval($content_width), $max_width ); 84 102 } 85 } elseif ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) && in_array( $size, array_keys( $_wp_additional_image_sizes ) ) ) {103 } elseif ( ! empty( $_wp_additional_image_sizes ) && in_array( $size, array_keys( $_wp_additional_image_sizes ) ) ) { 86 104 $max_width = intval( $_wp_additional_image_sizes[$size]['width'] ); 87 105 $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 ); 106 // Only in admin. Assume that theme authors know what they're doing. 107 if ( intval( $content_width ) > 0 && 'edit' === $context ) { 108 $max_width = min( intval( $content_width ), $max_width ); 109 } 90 110 } 91 111 // $size == 'full' has no constraint … … 259 279 * @since 3.9.0 260 280 * 261 * @global array $_wp_additional_image_sizes262 *263 281 * @param string $name The image size to check. 264 282 * @return bool True if the image size exists, false if not. 265 283 */ 266 284 function has_image_size( $name ) { 267 global $_wp_additional_image_sizes; 268 269 return isset( $_wp_additional_image_sizes[ $name ] ); 285 $sizes = wp_get_additional_image_sizes(); 286 return isset( $sizes[ $name ] ); 270 287 } 271 288 … … 749 766 * @since 3.0.0 750 767 * 751 * @global array $_wp_additional_image_sizes752 *753 768 * @return array Returns a filtered array of image size strings. 754 769 */ 755 770 function get_intermediate_image_sizes() { 756 global $_wp_additional_image_sizes;771 $_wp_additional_image_sizes = wp_get_additional_image_sizes(); 757 772 $image_sizes = array('thumbnail', 'medium', 'medium_large', 'large'); // Standard sizes 758 if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) )773 if ( ! empty( $_wp_additional_image_sizes ) ) { 759 774 $image_sizes = array_merge( $image_sizes, array_keys( $_wp_additional_image_sizes ) ); 775 } 760 776 761 777 /**
Note: See TracChangeset
for help on using the changeset viewer.