0

I have a blog on wordpress.com in which I make use of the Twenty Ten theme. For each Post I can set a Featured image.

On Wordpress.com that image is then displayed in the header above the menu.

I'd like to gain the same for a Wordpress.org setup. How can I do this?

2
  • 1
    isn't that already implemented in TwentyTen? I remember seeing the featured image in the header area.. Mar 25 '11 at 23:50
  • I'm running a 3.0.5 site and it is not working that way. I think I need to debug further because I thought as well, that it should already work that way.
    – hakre
    Mar 26 '11 at 2:34
2

Not sure I understand your question completely hakre but here is the code that shows the featured image for twenty-ten in header.php.The image sizing is defined in the functions.php file.

It also uses a function called http://codex.wordpress.org/Function_Reference/get_header_image.

<?php
                    // Check if this is a post or page, if it has a thumbnail, and if it's a big one
                    if ( is_singular() && current_theme_supports( 'post-thumbnails' ) &&
                            has_post_thumbnail( $post->ID ) &&
                            ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' ) ) &&
                            $image[1] >= HEADER_IMAGE_WIDTH ) :
                        // Houston, we have a new header image!
                        echo get_the_post_thumbnail( $post->ID );
                    elseif ( get_header_image() ) : ?>
                        <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
                    <?php endif; ?>
2
  • Thanks for the hint Wyck, it's probably related that I downloaded too small images and expected to get them blown up: $image[1] >= HEADER_IMAGE_WIDTH.
    – hakre
    Mar 29 '11 at 15:39
  • Yes it is [15 chars]
    – hakre
    Mar 29 '11 at 18:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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