WordPress.org

Ready to get started?Download WordPress

Forums

wp_get_attachment_image: Adding CSS Classes (1 post)

  1. Frisko
    Member
    Posted 1 year ago #

    Hi folks. With the function 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 does, isn't it? So is this a bug or is it the intended behavior of wp_get_attachment_image?

    @Dear Moderator: Don't know if this is the right forum for this question. If not, feel free to move it :)

Topic Closed

This topic has been closed to new replies.

About this Topic