Changeset 7263
- Timestamp:
- 03/12/2008 08:10:00 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/edit-attachment-rows.php
r7262 r7263 40 40 case 'icon': 41 41 ?> 42 <td class="media-icon"><?php echo get_the_attachment_link($post->ID, false, array(48,48)); ?></td>42 <td class="media-icon"><?php echo wp_get_attachment_link($post->ID, array(60, 40), false, true); ?></td> 43 43 <?php 44 44 // TODO -
trunk/wp-admin/user-edit.php
r7259 r7263 158 158 <td> 159 159 <?php 160 $current_color = get_user_option('admin_color'); 161 if ( empty($current_color) ) 162 $current_color = 'classic'; 160 163 foreach ( $_wp_admin_css_colors as $color => $color_info ): ?> 161 <label class="color-option"><input name="admin_color" type="radio" value="<?php echo $color ?>" class="tog" <?php checked($color, get_user_option('admin_color')); ?> />164 <label class="color-option"><input name="admin_color" type="radio" value="<?php echo $color ?>" class="tog" <?php checked($color, $current_color); ?> /> 162 165 <table class="color-palette"> 163 166 <tr> -
trunk/wp-includes/media.php
r7233 r7263 6 6 function image_constrain_size_for_editor($width, $height, $size = 'medium') { 7 7 8 if ( $size == 'thumb' ) { 8 if ( is_array($size) ) { 9 $max_width = $size[0]; 10 $max_height = $size[1]; 11 } 12 elseif ( $size == 'thumb' || $size == 'thumbnail' ) { 9 13 $max_width = intval(get_option('thumbnail_size_w')); 10 14 $max_height = intval(get_option('thumbnail_size_h')); … … 76 80 } 77 81 } 78 elseif (isset($meta['width'], $meta['height']) ) {82 if ( !$width && !$height && isset($meta['width'], $meta['height']) ) { 79 83 // any other type: use the real image and constrain it 80 84 list( $width, $height ) = image_constrain_size_for_editor( $meta['width'], $meta['height'], $size ); … … 251 255 if ( !$imagedata = wp_get_attachment_metadata( $post_id ) ) 252 256 return false; 253 254 if ( empty($imagedata['sizes'][$size]) ) 257 258 // get the best one for a specified set of dimensions 259 if ( is_array($size) && !empty($imagedata['sizes']) ) { 260 foreach ( $imagedata['sizes'] as $_size => $data ) { 261 // already cropped to width or height; so use this size 262 if ( ( $data['width'] == $size[0] && $data['height'] <= $size[1] ) || ( $data['height'] == $size[1] && $data['width'] <= $size[0] ) ) { 263 $file = $data['file']; 264 list($width, $height) = image_constrain_size_for_editor( $data['width'], $data['height'], $size ); 265 return compact( 'file', 'width', 'height' ); 266 } 267 // add to lookup table: area => size 268 $areas[$data['width'] * $data['height']] = $_size; 269 } 270 if ( !$size || !empty($areas) ) { 271 // find for the smallest image not smaller than the desired size 272 ksort($areas); 273 foreach ( $areas as $_size ) { 274 $data = $imagedata['sizes'][$_size]; 275 if ( $data['width'] >= $size[0] || $data['height'] >= $size[1] ) { 276 $file = $data['file']; 277 list($width, $height) = image_constrain_size_for_editor( $data['width'], $data['height'], $size ); 278 return compact( 'file', 'width', 'height' ); 279 } 280 } 281 } 282 } 283 284 if ( is_array($size) || empty($size) || empty($imagedata['sizes'][$size]) ) 255 285 return false; 256 286 … … 260 290 // get an image to represent an attachment - a mime icon for files, thumbnail or intermediate size for images 261 291 // returns an array (url, width, height), or false if no image is available 262 function wp_get_attachment_image_src($attachment_id, $size='thumbnail' ) {292 function wp_get_attachment_image_src($attachment_id, $size='thumbnail', $icon = false) { 263 293 264 294 // get a thumbnail or intermediate image if there is one … … 266 296 return $image; 267 297 268 if ( $ src = wp_mime_type_icon($attachment_id) ) {298 if ( $icon && $src = wp_mime_type_icon($attachment_id) ) { 269 299 $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/crystal' ); 270 300 $src_file = $icon_dir . '/' . basename($src); … … 277 307 278 308 // as per wp_get_attachment_image_src, but returns an <img> tag 279 function wp_get_attachment_image($attachment_id, $size='thumbnail' ) {309 function wp_get_attachment_image($attachment_id, $size='thumbnail', $icon = false) { 280 310 281 311 $html = ''; 282 $image = wp_get_attachment_image_src($attachment_id, $size );312 $image = wp_get_attachment_image_src($attachment_id, $size, $icon); 283 313 if ( $image ) { 284 314 list($src, $width, $height) = $image; 285 315 $hwstring = image_hwstring($width, $height); 316 if ( is_array($size) ) 317 $size = join('x', $size); 286 318 $html = '<img src="'.attribute_escape($src).'" '.$hwstring.'class="attachment-'.attribute_escape($size).'" />'; 287 319 } … … 323 355 324 356 foreach ( $attachments as $id => $attachment ) { 325 $link = get_the_attachment_link($id, false, array(128, 96), true);357 $link = wp_get_attachment_link($id, 'thumbnail', true); 326 358 $output .= " 327 359 <div> … … 359 391 360 392 if ( isset($attachments[$k]) ) 361 echo get_the_attachment_link($attachments[$k]->ID, true, array(128, 96), true);393 echo wp_get_attachment_link($attachments[$k]->ID, 'thumbnail', true); 362 394 } 363 395 -
trunk/wp-includes/post-template.php
r7172 r7263 371 371 372 372 // get an attachment page link using an image or icon if possible 373 function wp_get_attachment_link($id = 0, $size = 'thumbnail', $permalink = false ) {373 function wp_get_attachment_link($id = 0, $size = 'thumbnail', $permalink = false, $icon = false) { 374 374 $_post = & get_post( intval($id) ); 375 375 … … 382 382 $post_title = attribute_escape($_post->post_title); 383 383 384 $link_text = wp_get_attachment_image($id, $size );384 $link_text = wp_get_attachment_image($id, $size, $icon); 385 385 if ( !$link_text ) 386 386 $link_text = $_post->post_title;
Note: See TracChangeset
for help on using the changeset viewer.