Title: wp_get_attachment_image: Adding CSS Classes
Last modified: August 20, 2016

---

# wp_get_attachment_image: Adding CSS Classes

 *  [Frisko](https://wordpress.org/support/users/frisko/)
 * (@frisko)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/wp_get_attachment_image-adding-css-classes/)
 * Hi folks. With the function [`wp_get_attachment_image`](http://codex.wordpress.org/Function_Reference/wp_get_attachment_image)
   I can get an image-attachment as html img element. The element has a CSS class
   of ‘attachment-$size’ ($size is replaced by the argument you call the function
   with).
 * Now I want to add a CSS class to have something like <img class=”attachment-medium
   someclass”… />.
 * I thought this could be done with `wp_get_attachment_image( $attachment_id, $
   size, $icon, $attr=array('class' => 'someclass') )`…But this replaces the default
   class ‘attachment-$size’ with ‘someclass’.
 * It’s supposed to merge/append additional classes like [`the_post_thumbnail`](http://codex.wordpress.org/Function_Reference/the_post_thumbnail)
   does, isn’t it? So is this a bug or is it the intended behavior of `wp_get_attachment_image`?
 * [@dear](https://wordpress.org/support/users/dear/) Moderator: Don’t know if this
   is the right forum for this question. If not, feel free to move it 🙂

The topic ‘wp_get_attachment_image: Adding CSS Classes’ is closed to new replies.

## Tags

 * [wp_get_attachment_image()](https://wordpress.org/support/topic-tag/wp_get_attachment_image/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [Frisko](https://wordpress.org/support/users/frisko/)
 * Last activity: [13 years, 4 months ago](https://wordpress.org/support/topic/wp_get_attachment_image-adding-css-classes/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
