• I would like to set a different featured image for each page on my website. I’m able to specify an image, and a thumbnail of that image shows up in the Featured Image area on the Edit Page screen. However, it doesn’t show up on my site. What am I doing wrong?

    My site is currently at http://shop.writersrefuge.com/.

Viewing 15 replies - 1 through 15 (of 19 total)
  • What Theme are you using?

    Maybe the template doesn’t have featured images built in? Try adding the following to the the page.php or loop.php files.

    <?php the_post_thumbnail(); ?>

    There is information in the Codex.

    Ah, I missed your tag. It appears that you’re using the Adventure Journal Theme?

    The current version of this Theme appears to support displaying the Post Thumbnail on the blog post index (i.e. “home”). From loop.php:

    <?php if(is_home() && has_post_thumbnail()) the_post_thumbnail(); ?>

    Where are you seeing/not seeing the Post Thumbnail displayed?

    Thread Starter PetraMartin

    (@petramartin)

    I’m afraid I don’t know what you mean by post thumbnail.

    I can choose from among the four header images that Adventure Journal came with. Or I can upload my own. Whatever I do there is universal across the site.

    However, the featured image on a page should replace the header image on that page, and it’s not happening.

    This is my first wordpress.org site. My experience so far has been with wordpress.com sites, where this using a featured image has worked flawlessly so far. I don’t know how to make it work on a wordpress.org site.

    I’m afraid I don’t know what you mean by post thumbnail.

    “Post Thumbnail” = “Featured Image”

    However, the featured image on a page should replace the header image on that page, and it’s not happening.

    Yes, that is indeed a problem. Adenture Journal mimics TwentyTen, in that it uses the Post Thumbnail as the header image on the single post view. So, if you have assigned an image as the “Featured Image” it should show up as the header image on the single-post view.

    Let me go look at the code again…

    It is, in fact, a bug in Adventure Journal: the Theme never actually attempts to output the Post Thumbnail as the header image.

    Here’s the header image code from header.php:

    <div id="banner"><img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>"/></div>

    Compare that to the header image code in TwentyTen:

    <?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; ?>

    You should let the Theme developer know!

    Thread Starter PetraMartin

    (@petramartin)

    Thank you, Chip. I posted a comment on the Adventure Journal page and hope I get a response.

    We’re on it. πŸ™‚

    So I am trying to load a custom image for the twenty ten theme as well. But I am unable to do so. I am not sure what changes to make in my header.php for it to make it work?

    So I’ve done a lot of digging around lately to figure this out, and it seems that even TwentyTen handles this in a way that will probably never work. Here’s what’s happening:

    The header art and “featured image” art for posts are both preset to ensure they work with various layouts. Here’s the catch, there are two possible uses for featured images – and they seem to be mutually exclusive without a lot of extra work.

    On one hand, you can have featured images appear in the loop – so they’re visible on blog listings and singular pages at the top of the post. This is our usage.

    On the other hand, you use featured images to override the header graphic. In the case of TwentyTen and Adventure Journal, the size of the “featured image” will always be smaller than the header graphic, so it just plain won’t work up there – and the code that exists now isn’t really made to handle multiple simultaneous sizes for the featured image so we can’t really have both without essentially creating a big ol plugin for it.

    So here’s how we decided to handle this:
    We’ll be adding an option to Appearance > Adventure Journal that says “Use Featured Images as Header”. If checked, featured images will never appear in loops, but will replace the site header graphic on singular pages instead (when available).

    Having these two usages be mutually exclusive isn’t ideal, but until I get a little more familiar with WordPress’s lower-level media handling, it’s the best I can think of without throwing a whole ton of work at it.

    This feature will be available in 1.5 some time next week.

    I honestly don’t like the way that TwentyTen handles Post-Thumbnails-as-Header-Image.

    IMHO, the more correct implementation would have been to define a custom header-post-thumbnail image size in functions.php, e.g. via:

    add_image_size( 'header-post-thumbnail', 940, 198 );

    (Or whatever the dimensions are.)

    That way, Whenever an image is uploaded to the Media Manager, the custom image size is generated, with soft-crop.

    Then, the header code simply needs to output the header post thumbnail if it exists.

    I tried that approach and couldn’t get it to work. Take this line in TwentyTen’s header.php:

    $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' ) )

    If you change 'post-thumbnail' in wp_get_attachment_image_src() to ‘full’, nothing is returned. It seems that get_post_thumbnail_id( $post->ID ) refers specifically to the smaller, pre-cropped/resized featured image and so it can’t be used to fetch a different size of the same source image.

    I could be mistaken, but so far I haven’t figured out how to use the featured image metadata to identify the SOURCE image and then fetch a different size for use in the site header (ie: ‘full’ or ‘custom-image-size’).

    I may just need to spend more time acquainting myself with WordPress’s media functions.

    Thread Starter PetraMartin

    (@petramartin)

    Veraxus, I just installed version 1.5.1, and checked the “Use featured images as custom site header, if available” on the Adventure Journal Options page, but featured images still aren’t appearing on individual pages. Did I misunderstand something?

    Hey Petra,

    Because of WordPress’s quirky treatment of featured images, you have to follow an exacting process to get them to work correctly.

    1. Ensure “Use featured images as custom site header, if available” on the Adventure Journal appearance page.
    2. On any page/post edit screen, select “Choose featured image”
    3. Click “Select files” Important: You MUST upload a new file for this to work. WordPress only generates featured images of the correct size the first time you upload.
    4. Choose an image on your computer that is 920 px wide OR MORE (if the image is smaller, it will not show). The image can be any height, only the width is checked.
    5. When the image is uploaded, be sure to click “Use as featured image”
    6. Save the post, and view it on your website

    Here’s an explanation of the quirk that prevents this from working for most people:

    • Any images you uploaded BEFORE checking the “Use featured images as custom site header” option (even if they are in your media library and not assigned to a page or post) will NOT appear on the site header. You MUST upload new images or they will not appear in the header.

    The reason for this is that WordPress processes the image only when you upload it, saving a version to use for the header. This is usually 485 px or 665 px wide, depending on the layout you have selected.

    In order for an image to appear in the header, the header version of the image MUST be 920 px or wider. If you’ve already uploaded an image, WordPress has a smaller version saved, and that version doesn’t pass the width check in the header.php theme file (the image width is checked to prevent ugly half-width headers).

    The solution is simply to upload the image again, ensuring that it’s wide enough (920px+).

    Please let me know if this helps.

    As a side-note, I’m working on a complete rebuild of Adventure Journal – which includes a hand-crafted custom header system. It’s pretty obvious that WordPress’s featured images are a really ineffective tool for achieving this kind of functionality. That version might be a month or two down the road.

    Actually, there’s another solution: use the Regenerate Thumbnails Plugin, or similar, to regenerate the Thumbnails in the DB.

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘Cannot set featured image’ is closed to new replies.