[wp-trac] [WordPress Trac] #19013: wp_get_attachment_image not working as expected

WordPress Trac wp-trac at lists.automattic.com
Thu Oct 20 08:31:46 UTC 2011


#19013: wp_get_attachment_image not working as expected
--------------------------+-----------------------------
 Reporter:  ramaboo       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 Assume the following bit of code:

 wp_get_attachment_image(1, 'thumbnail', false, array('title' => 'fobar'));

 It will produce something like this:
 <img width="150" height="150" src="http://testcrave.genome.ramaboo.com/wp-
 content/uploads/2011/10/DC040811-RW23-150x150.jpg" class="attachment-
 thumbnail" alt="DC040811 RW23 150x150 gallery" title="foobar" />

 as expected!

 Now try this:
 wp_get_attachment_image(1, 'thumbnail', false, array('alt' => 'fobar'));

 and the result is:
 <img width="150" height="150" src="http://testcrave.genome.ramaboo.com/wp-
 content/uploads/2011/10/DC040811-RW23-150x150.jpg" class="attachment-
 thumbnail" alt="DC040811 RW23 150x150 gallery" title="DC040811-RW23" />

 I would expect it to honor the alt attribute but instead the system uses
 the default alt attribute. According to the documentation
 http://codex.wordpress.org/Function_Reference/wp_get_attachment_image
 passing in array('alt' => 'foobar') for $attr should be valid.

 I also tried it with array('class' => 'foobar') and array('foo' =>
 'foobar') and both worked as expected. The only one I have found that does
 not work is array('alt' => 'foobar').

 David

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/19013>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list