Changeset 7149
- Timestamp:
- 03/04/2008 04:21:37 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/schema.php
r7148 r7149 248 248 add_option('thumbnail_size_h', 150); 249 249 add_option('thumbnail_crop', 1); 250 add_option('medium_size_w', '');251 add_option('medium_size_h', '');250 add_option('medium_size_w', 300); 251 add_option('medium_size_h', 300); 252 252 add_option('autosave_interval', 60); 253 253 -
trunk/wp-includes/media.php
r7137 r7149 19 19 $max_height = intval(get_option('medium_size_h')); 20 20 // if no width is set, default to the theme content width if available 21 if ( !$max_width ) {22 // $content_width might be set in the current theme's functions.php23 if ( !empty($GLOBALS['content_width']) ) {24 $max_width = $GLOBALS['content_width'];25 }26 else27 $max_width = 500;28 }29 21 } 30 22 else { // $size == 'full' 31 $max_width = 0; 32 $max_height = 0; 23 // we're inserting a full size image into the editor. if it's a really big image we'll scale it down to fit reasonably 24 // within the editor itself, and within the theme's content width if it's known. the user can resize it in the editor 25 // if they wish. 26 if ( !empty($GLOBALS['content_width']) ) { 27 $max_width = $GLOBALS['content_width']; 28 } 29 else 30 $max_width = 500; 33 31 } 34 32 … … 259 257 } 260 258 259 // get an image to represent an attachment - a mime icon for files, thumbnail or intermediate size for images 260 // returns an array (url, width, height), or false if no image is available 261 function wp_get_attachment_image_src($attachment_id, $size='thumbnail') { 262 263 // get a thumbnail or intermediate image if there is one 264 $image = image_downsize($attachment_id, $size); 265 if ( $image ) { 266 list ( $src, $width, $height ) = $image; 267 } 268 elseif ( $src = wp_mime_type_icon($attachment_id) ) { 269 $icon_dir = apply_filters( 'icon_dir', get_template_directory() . '/images' ); 270 $src_file = $icon_dir . '/' . basename($src); 271 @list($width, $height) = getimagesize($src_file); 272 } 273 274 if ( $src && $width && $height ) 275 return array( $src, $width, $height ); 276 return false; 277 } 278 279 // as per wp_get_attachment_image_src, but returns an <img> tag 280 function wp_get_attachment_image($attachment_id, $size='thumbnail') { 281 282 $html = ''; 283 $image = wp_get_attachment_image_src($attachment_id, $size); 284 if ( $image ) { 285 list($src, $width, $height) = $image; 286 $hwstring = image_hwstring($width, $height); 287 $html = '<img src="'.attribute_escape($src).'" '.$hwstring.'class="attachment-'.attribute_escape($size).'" />'; 288 } 289 290 return $html; 291 } 261 292 262 293 ?> -
trunk/wp-includes/post-template.php
r7135 r7149 363 363 // 364 364 365 function the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) { 366 echo get_the_attachment_link($id, $fullsize, $max_dims, $permalink); 367 } 368 365 function the_attachment_link($id = 0, $fullsize = false, $deprecated = false, $permalink = false) { 366 if ( $fullsize ) 367 echo wp_get_attachment_link($id, 'full', $permalink); 368 else 369 echo wp_get_attachment_link($id, 'thumbnail', $permalink); 370 } 371 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) { 374 $_post = & get_post( intval($id) ); 375 376 if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) ) 377 return __('Missing Attachment'); 378 379 if ( $permalink ) 380 $url = get_attachment_link($_post->ID); 381 382 $post_title = attribute_escape($_post->post_title); 383 384 $link_text = wp_get_attachment_image($attachment_id, $size); 385 if ( !$link_text ) 386 $link_text = $_post->post_title; 387 388 return "<a href='$url' title='$post_title'>$link_text</a>"; 389 390 } 391 392 // deprecated - use wp_get_attachment_link() 369 393 function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) { 370 394 $id = (int) $id; … … 383 407 } 384 408 409 410 // deprecated: use wp_get_attachment_image_src() 385 411 function get_attachment_icon_src( $id = 0, $fullsize = false ) { 386 412 $id = (int) $id; … … 414 440 } 415 441 442 // deprecated: use wp_get_attachment_image() 416 443 function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) { 417 444 $id = (int) $id; 418 445 if ( !$post = & get_post($id) ) 419 446 return false; 420 447 421 448 if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) ) 422 449 return false; … … 457 484 } 458 485 486 // deprecated: use wp_get_attachment_image() 459 487 function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) { 460 488 $id = (int) $id; … … 473 501 function prepend_attachment($content) { 474 502 $p = '<p class="attachment">'; 475 $p .= get_the_attachment_link(false, true, array(400, 300)); 503 // show the medium sized image representation of the attachment if available, and link to the raw file 504 $p .= wp_get_attachment_link(0, 'medium', false); 476 505 $p .= '</p>'; 477 506 $p = apply_filters('prepend_attachment', $p);
Note: See TracChangeset
for help on using the changeset viewer.