From 45b4ea58074cd8af896f268699d9f538a75ac912 Mon Sep 17 00:00:00 2001 From: Mark Jaquith Date: Thu, 15 Oct 2009 12:31:48 +0000 Subject: [PATCH] Allow theme devs to change attrs (like CSS class) of thumbnail images. props scribu. see #10928 git-svn-id: https://develop.svn.wordpress.org/trunk@12035 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/media.php | 7 ++++--- wp-includes/post-template.php | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/wp-includes/media.php b/wp-includes/media.php index cf671c469a..a8493562b8 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -527,7 +527,7 @@ function wp_get_attachment_image_src($attachment_id, $size='thumbnail', $icon = * @param bool $icon Optional, default is false. Whether it is an icon. * @return string HTML img element or empty string on failure. */ -function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = false) { +function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = false, $attr = '') { $html = ''; $image = wp_get_attachment_image_src($attachment_id, $size, $icon); @@ -537,12 +537,13 @@ function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = fa if ( is_array($size) ) $size = join('x', $size); $attachment =& get_post($attachment_id); - $attr = array( + $default_attr = array( 'src' => $src, 'class' => "attachment-$size", 'alt' => trim(strip_tags( $attachment->post_excerpt )), 'title' => trim(strip_tags( $attachment->post_title )), - ); + ); + $attr = wp_parse_args($attr, $default_attr); $attr = apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment ); $attr = array_map( 'esc_attr', $attr ); $html = rtrim("