Changeset 12342
- Timestamp:
- 12/08/2009 09:08:19 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/image.php
r12163 r12342 99 99 100 100 // make thumbnails and other intermediate sizes 101 $sizes = apply_filters( 'intermediate_image_sizes', array('thumbnail', 'medium', 'large') ); 102 103 foreach ($sizes as $size) { 104 $resized = image_make_intermediate_size( $file, get_option("{$size}_size_w"), get_option("{$size}_size_h"), get_option("{$size}_crop") ); 101 global $_wp_additional_image_sizes; 102 $temp_sizes = array('thumbnail', 'medium', 'large'); // Standard sizes 103 if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) ) 104 $temp_sizes = array_merge( $temp_sizes, array_keys( $_wp_additional_image_sizes ) ); 105 106 $temp_sizes = apply_filters( 'intermediate_image_sizes', $temp_sizes ); 107 108 foreach ( $temp_sizes as $s ) { 109 $sizes[$s] = array( 'width' => '', 'height' => '', 'crop' => FALSE ); 110 if ( isset( $_wp_additional_image_sizes[$s]['width'] ) ) 111 $sizes[$s]['width'] = intval( $_wp_additional_image_sizes[$s]['width'] ); // For theme-added sizes 112 else 113 $sizes[$s]['width'] = get_option( "{$size}_size_w" ); // For default sizes set in options 114 if ( isset( $_wp_additional_image_sizes[$s]['height'] ) ) 115 $sizes[$s]['height'] = intval( $_wp_additional_image_sizes[$s]['height'] ); // For theme-added sizes 116 else 117 $sizes[$s]['height'] = get_option( "{$size}_size_h" ); // For default sizes set in options 118 if ( isset( $_wp_additional_image_sizes[$s]['crop'] ) ) 119 $sizes[$s]['crop'] = intval( $_wp_additional_image_sizes[$s]['crop'] ); // For theme-added sizes 120 else 121 $sizes[$s]['crop'] = get_option( "{$size}_crop" ); // For default sizes set in options 122 } 123 124 $sizes = apply_filters( 'intermediate_image_sizes_advanced', $sizes ); 125 126 foreach ($sizes as $size => $size_data ) { 127 $resized = image_make_intermediate_size( $file, $size_data['width'], $size_data['height'], $size_data['crop'] ); 105 128 if ( $resized ) 106 129 $metadata['sizes'][$size] = $resized; -
trunk/wp-admin/includes/post.php
r12336 r12342 1071 1071 */ 1072 1072 function _wp_post_thumbnail_html( $thumbnail_id = NULL ) { 1073 global $content_width, $_wp_additional_image_sizes; 1073 1074 $content = '<p class="hide-if-no-js"><a href="#" id="set-post-thumbnail" onclick="jQuery(\'#add_image\').click();return false;">' . esc_html__( 'Set thumbnail' ) . '</a></p>'; 1074 1075 1075 1076 if ( $thumbnail_id && get_post( $thumbnail_id ) ) { 1076 $thumbnail_html = wp_get_attachment_image($thumbnail_id, array( 266, 266 ) ); 1077 $old_content_width = $content_width; 1078 $content_width = 266; 1079 if ( !isset( $_wp_additional_image_sizes['post-image'] ) ) 1080 $thumbnail_html = wp_get_attachment_image( $thumbnail_id, array( $content_width, $content_width ) ); 1081 else 1082 $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-image' ); 1077 1083 if ( !empty( $thumbnail_html ) ) { 1078 1084 $content = '<a href="#" id="set-post-thumbnail" onclick="jQuery(\'#add_image\').click();return false;">' . $thumbnail_html . '</a>'; 1079 1085 $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail();return false;">' . esc_html__( 'Remove thumbnail' ) . '</a></p>'; 1080 1086 } 1087 $content_width = $old_content_width; 1081 1088 } 1082 1089 -
trunk/wp-includes/media.php
r12338 r12342 33 33 */ 34 34 function image_constrain_size_for_editor($width, $height, $size = 'medium') { 35 global $content_width ;35 global $content_width, $_wp_additional_image_sizes; 36 36 37 37 if ( is_array($size) ) { … … 62 62 if ( intval($content_width) > 0 ) 63 63 $max_width = min( intval($content_width), $max_width ); 64 } elseif ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) && in_array( $size, array_keys( $_wp_additional_image_sizes ) ) ) { 65 $max_width = intval( $_wp_additional_image_sizes[$size]['width'] ); 66 $max_height = intval( $_wp_additional_image_sizes[$size]['height'] ); 67 if ( intval($content_width) > 0 ) 68 $max_width = min( intval($content_width), $max_width ); 64 69 } 65 70 // $size == 'full' has no constraint … … 168 173 return false; 169 174 175 } 176 177 /** 178 * Registers a new image size 179 */ 180 function add_image_size( $name, $width = 0, $height = 0, $crop = FALSE ) { 181 global $_wp_additional_image_sizes; 182 $_wp_additional_image_sizes[$name] = array( 'width' => absint( $width ), 'height' => absint( $height ), 'crop' => !!$crop ); 183 } 184 185 /** 186 * Registers an image size for the post image 187 */ 188 function set_post_image_size( $width = 0, $height = 0, $crop = FALSE ) { 189 add_image_size( 'post-image', $width, $height, $crop ); 170 190 } 171 191 -
trunk/wp-includes/post-image-template.php
r12339 r12342 43 43 * @since 2.9.0 44 44 * 45 * @param int $size Optional. Image size. Defaults to ' thumbnail'.45 * @param int $size Optional. Image size. Defaults to 'post-image', which theme sets using set_post_image_size( $width, $height, $crop_flag );. 46 46 * @param string|array $attr Optional. Query string or array of attributes. 47 47 */ 48 function the_post_image( $size = ' thumbnail', $attr = '' ) {48 function the_post_image( $size = 'post-image', $attr = '' ) { 49 49 echo get_the_post_image( NULL, $size, $attr ); 50 50 } … … 59 59 * @param string|array $attr Optional. Query string or array of attributes. 60 60 */ 61 function get_the_post_image( $post_id = NULL, $size = ' thumbnail', $attr = '' ) {61 function get_the_post_image( $post_id = NULL, $size = 'post-image', $attr = '' ) { 62 62 global $id; 63 63 $post_id = ( NULL === $post_id ) ? $id : $post_id;
Note: See TracChangeset
for help on using the changeset viewer.