1

I am using wordpress 3.1 and when I use the featured image metabox to upload sometimes I see in my posts the image as part of the content and sometimes the header image changes as well. I cannot understand what is the reason. Any help will be appreciated.

I am using

    if ( has_post_thumbnail() ) 
{ // check if the post has a Post Thumbnail assigned to it.
    the_post_thumbnail();
} 

Update

sorry i got confused with the editor. anyway what i need right now is to display the thumbnail in a size of 300x300 but have a larger image to display when the user clicks on the thumbnail. i saw the loop-attachment.php and i think i have to use this one.

<?php $attachment_page = get_attachment_link( $attachment_id ); ?>
                <?php $thumb=get_the_post_thumbnail(); ?>
                    <a href="<?php echo $attachment_page; ?>">
                    <?php the_post_thumbnail();?>
                    </a>

but it is not working. i dont know if i have to post it as a new question also.

2
  • What Theme are you using? The implementation of the Post Thumbnail (i.e. "featured image") feature is entirely Theme-dependent. Commented Jul 19, 2011 at 14:09
  • 1
    Sounds like he is using Twrnty Ten or Twenty Eleven
    – Pippin
    Commented Jul 19, 2011 at 14:12

1 Answer 1

3

Assuming you are using Twenty Ten, Twenty Eleven, or one of the several Themes that derive Post Thumbnail (i.e. "featured image") feature handling from either of these Themes:

  • The Featured Image is applied to the header image, if and only if the dimensions of the Featured Image exceed the dimensions of the header image.
  • The Featured Image is not displayed in the Post Content by default; you must manually insert the Featured Image into the Post Content, as you would any other image, if you want it to appear in your Post.

EDIT

To have a custom image size, such as 300x300, you can use add_image_size(). For example, add the following to functions.php:

add_image_size( 'single-post-image', 300, 300, true );

Then, in single.php, you can add:

<?php the_post_thumbnail( 'single-post-image' ); ?>

And your 300x300px image will be inserted wherever you place it.

(Note: you may need to regenerate existing Thumbnails.)

EDIT

To link your displayed, custom-sized featured image to its attachment-page view, you need to use get_attachment_link(). In single.php:

<?php if ( has_post_thumbnail() ) { ?>
    <a href="<?php echo get_attachment_link( get_post_thumbnail_id() ); ?>">
    <?php the_post_thumbnail( 'single-post-image' ); ?>
    </a>
<?php } ?>
6
  • So does this answer your question, or do you still have questions about Twenty Ten's handling of featured images? Commented Jul 20, 2011 at 11:37
  • hi,yes i am using the theme twenty ten. i used the above code to display it in single.php. also i found in functions.php the comments that states that any image bigger than 940 will be cropped and used as a header. i also set in the functions.php the post_thumbnail_size(300,300,true) and now i think i have what i need. Seems to me really strange the whole thing mixing thumbnail support and header images...At the moment i get my thumbnail with 300x300 dimensions .
    – dimitris
    Commented Jul 20, 2011 at 11:59
  • Do you want the featured image to display in the Post without having to add it manually? Or do you just need to know how to get the user to the full-size image once you've inserted it into the Post? Commented Jul 20, 2011 at 12:04
  • i will try to describe the whole thing. so i have a custom type ad and the author of the ad ads a new ad with an image. i am using the featured image for that. so after that in single.php i see the 300x300 image. i dont know how to let the user upload a bigger image . and then present it in single.php as an 300x300 with a link to the full size. thank you for everything.
    – dimitris
    Commented Jul 20, 2011 at 12:11
  • Okay, see updated answer. Commented Jul 20, 2011 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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