WordPress.org

Ready to get started?Download WordPress

Forums

Attachments
[resolved] First instance (6 posts)

  1. videogramme
    Member
    Posted 1 year ago #

    Hi,

    how exactly do i get the first "thumbnail" attach to a post ?

    I have multiple images attache on my post.
    But i need to just take the first image in thumbnail size.
    If have got this code that display all attached images in thumbnail size :

    $attachments = new Attachments( 'my_attachments' );
    	if( $attachments->exist() ) :
        	    while( $attachments->get() ) :
           		$attachments->image( 'thumbnail' ));
                endwhile;
    	endif;

    thanks in advance.

    http://wordpress.org/extend/plugins/attachments/

  2. Jonathan Christopher
    Member
    Plugin Author

    Posted 1 year ago #

    Hi, check out the usage docs to see that you need to echo your call to image():

    $attachments = new Attachments( 'my_attachments' );
    if( $attachments->exist() ) :
        while( $attachments->get() ) :
            echo $attachments->image( 'thumbnail' );
        endwhile;
    endif;

    If you enjoy Attachments please take a second to rate and review!

  3. videogramme
    Member
    Posted 1 year ago #

    Hi,

    Thanks for the fast respons.
    Sorry it was a copy error.
    But i still don't know how to display only the first attached image.
    Help will be much appreciat.

    Thx in advance

    [Don't bump]

  4. videogramme
    Member
    Posted 1 year ago #

    it's not resolved pls give me some help

  5. Jonathan Christopher
    Member
    Plugin Author

    Posted 1 year ago #

    $attachments = new Attachments( 'my_attachments' );
    if( $attachments->exist() ) :
        $attachments->get();
        echo $attachments->image( 'thumbnail' );
    endif;
  6. videogramme
    Member
    Posted 1 year ago #

    Thank you verry much. It work like a charme. Your awesome ; )

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic