Forums

[resolved] Featured Image not showing in custom slot (8 posts)

  1. fateskimo
    Member
    Posted 9 months ago #

    Hi

    I'm having trouble with my featured images in pages not replacing the custom image in the header. I've made sure it's the correct size but it keeps showing the custom uploaded header image from the front page.

    I have moved the code from the header.php to sidebar-page.php as it needs to sit to the right of the content. Could this be the problem? Does the code have to sit inside the header.php?

    Any suggestions would be very welcome.

  2. A link to your site and/or a pastebin.com link to your PHP code would help us.

  3. fateskimo
    Member
    Posted 9 months ago #

    Apologies, I'm developing it on my localhost.

    here's a link to the pastebin of the sidebar-page.php...

    http://pastebin.com/4dXBjpcS

    Cheers

  4. fateskimo
    Member
    Posted 9 months ago #

    I've changed everything back to how it was and it worked but when I changed the image size change in the child theme functions.php from the default to 300px wide and 600px high it stopped working again.

    Is there a problem with Portrait featured images?

  5. alchymyth
    The Sweeper & Moderator
    Posted 9 months ago #

    untested - try to change this line to:

    ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT ) ) ) &&
  6. fateskimo
    Member
    Posted 9 months ago #

    Dude, I could kiss you right now.

    That worked a charm. You have just saved the very last strands of hair I have left after two days of head butting a wall.

  7. alchymyth
    The Sweeper & Moderator
    Posted 9 months ago #

    you are welcome ;-)

    if this is all sorted, please tick the topic off as 'resolved' - thanks ;-)

    PS:
    I always wondered why HEADER_IMAGE_WIDTH (or $header_image_width resp.) was used twice in that code; now I know ...

    just in case somebody else wants to have a portrait-sized header image in (a child theme of) Twenty Eleven:
    the universal code - to allow for landscape and portrait images - should be:

    (for Twenty Eleven 1.4 which is slightly different to the earlier versions)

    // Check if this is a post or page, if it has a thumbnail, and if it's a big one
    					if ( is_singular() && has_post_thumbnail( $post->ID ) &&
    							( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( $header_image_width, max($header_image_width,$header_image_height) ) ) ) &&
    							$image[1] >= $header_image_width ) :
    						// Houston, we have a new header image!
  8. fateskimo
    Member
    Posted 9 months ago #

    Will do, cheers!!

Reply

You must log in to post.

About this Topic