Ticket #8732: wp_get_attachment_image_alt.diff
File wp_get_attachment_image_alt.diff, 1.4 KB (added by , 16 years ago) |
---|
-
wp-includes/media.php
514 514 } 515 515 516 516 /** 517 * Retrieve img HTML content for an image to represent an attachment.517 * Get an HTML img element representing an image attachment 518 518 * 519 * @see wp_get_attachment_image_src() Returns img HTML element based on array. 519 * @uses apply_filters() Calls 'wp_get_attachment_image_attributes' hook on attributes array 520 * @uses wp_get_attachment_image_src() Gets attachment file URL and dimensions 520 521 * @since 2.5.0 521 522 * 522 523 * @param int $attachment_id Image attachment ID. … … 533 534 $hwstring = image_hwstring($width, $height); 534 535 if ( is_array($size) ) 535 536 $size = join('x', $size); 536 $html = '<img src="'.attribute_escape($src).'" '.$hwstring.'class="attachment-'.attribute_escape($size).'" alt="" />'; 537 $attachment =& get_post($attachment_id); 538 $attr = array( 539 'src' => $src, 540 'class' => "attachment-$size", 541 'alt' => trim(strip_tags( $attachment->post_excerpt )), 542 'title' => trim(strip_tags( $attachment->post_title )), 543 ); 544 $attr = apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment ); 545 $attr = array_map( 'attribute_escape', $attr ); 546 $html = rtrim("<img $hwstring"); 547 foreach ( $attr as $name => $value ) { 548 $html .= " $name=" . '"' . $value . '"'; 549 } 550 $html .= ' />'; 537 551 } 538 552 539 553 return $html;