Opened 14 years ago
Closed 14 years ago
#19013 closed defect (bug) (invalid)
wp_get_attachment_image not working as expected
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | |
| Component: | General | Keywords: | reporter-feedback |
| Focuses: | Cc: |
Description
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
I've checked this on 3.2.1 and 3.3-beta2, and the
altattribute is changed accordingly.