[resolved] How to use original size image for header as Twenty Twelve does? (3 posts)

  1. Tomas Mackevicius
    Posted 2 years ago #


    I'm trying to port Twenty Eleven custom header for post/page feature to Twenty Twelve. I combined the code from both themes in header.php, but for some reason post/page header is inserted as Large, not as original as Twenty Twelve does. Here is the original Twenty Twelve code:


    Here is my header.php code:


    Looks like this part is responsible:

    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, $header_image_width ) ) ) &&
    				$image[1] >= $header_image_width ) :
    		// Houston, we have a new header image!
    		echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );

    What should I change so I could get the output with image of full size and without width and height specified?

    Also in Twenty eleven code the part array( $header_image_width, $header_image_width ) looks like mistake, because width is written twice, unless there is some kind of hack.

    Here is the default header - works OK:


    Post/page header is inserted as Large:


    Thank you for your help!

  2. paulwpxp
    Font hero
    Posted 2 years ago #

    It's this line (#L19 of http://pastebin.com/UzRX6h1k )

    echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );

    The post-thumbnail size is set in TwentyTwelve's function.php as 624px, so what you see is not size = large, what you see is size = post-thumbnail = 624px.

    I would change it to full AND upload the image with exact 960px only, ( this is my personal default image dimension used for web )


    I would change it to large AND set the value of large in Admin > Media settings as 960px.


    you can alter the post-thumbnail size set in TwentyTwelve to be 960px instead of 624px, but you will lose the 624px that used in normal post.


    register new image size and use that in #L19

  3. Tomas Mackevicius
    Posted 2 years ago #

    Thank you, Paul!

    I tried with full and it worked, but just to make it easy for people who may not have graphic software to prepare image with special dimensions, I will register new size (also with 960px), so it will be super easy :)

    Thank you again!

Topic Closed

This topic has been closed to new replies.

About this Topic