WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] wp_get_attachment_image change class (2 posts)

  1. brian914
    Member
    Posted 3 years ago #

    I am using wp_get_attachment_image() to retrive one of my images, but would like to be able to add a different class to the image. Right now, I am getting this:

    <img class="attachment-full" width="230" height="160" title="thumb" alt="thumb" src="http://localhost:8888/agilitygraphics/wp-content/uploads/2011/05/agility.jpg">

    So instead of the "attachment-full" I want to either add another class, or one instead.

    How can I do that?

    Thanks a lot for any help with this!

  2. brian914
    Member
    Posted 3 years ago #

    I figured it out and did something like the following:

    $imageUrl = wp_get_attachment_image_src( $attachment->ID, 'full' );

    echo '<img class="myCustomClass" src="'; echo $imageUrl[0]; echo '"/> ';

Topic Closed

This topic has been closed to new replies.

About this Topic