Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Does anyone know how can I display in the loop thumbnail's name, alternative text, title, caption, url?

Thx for all advices and suggestions

share|improve this question
1  
possible duplicate of How To Retrieve An Image Attachment's Alt Text? –  brasofilo Jul 24 '12 at 13:37

1 Answer 1

up vote 2 down vote accepted

Try the following code inside the loop and modify it as per requirement.

$thumb_id = get_post_thumbnail_id();
echo 'Name = '.  get_post_field( 'post_name', $thumb_id ).'<br />';
echo 'Alt = '.  get_post_meta( $thumb_id, '_wp_attachment_image_alt', true ).'<br />';
echo 'Title = '.  get_the_title( $thumb_id ).'<br />';
echo 'Caption = '.  get_post_field( 'post_excerpt', $thumb_id ).'<br />';
echo 'Description = '.  get_post_field( 'post_content', $thumb_id ).'<br />';
echo 'SRC = '. wp_get_attachment_url( $thumb_id ).'<br />';
echo 'URL = '. get_permalink( $thumb_id ).'<br />';
share|improve this answer
    
This is exactly what I need thank you very much :) –  Jakub Kohout Jul 24 '12 at 13:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.