• Resolved invaderB

    (@invaderb)


    Hey,

    I’m trying to change the height of the header image when you set a featured image on a page, by default it sets it to 1000×288 but I need 1000×400

    I’ve tried changing it in the functions.php file

    <br />
    'width' => apply_filters( 'twentyeleven_header_image_width', 1000 ),<br />
    		'height' => apply_filters( 'twentyeleven_header_image_height', 400 ),<br />

    also tried adding this in to my child functions file

    <br />
    function my_header_image_height($height) {<br />
    	return 150;<br />
    }<br />
    add_filter( 'twentyeleven_header_image_height', 'my_header_image_height');<br />

    If any one has come across this and knows a resolution
    http://www.paulmetzgerandassociates.com/wp/

    Using wordpress 3.6
    twenty eleven with child theme version 1.6

Viewing 7 replies - 1 through 7 (of 7 total)
  • Check out these links: this and this.

    by default it sets it to 1000×288 but I need 1000×400

    I think you could just upload that size and it will be used, because theme supports flexible height in custom header.

    http://themes.trac.ww.wp.xz.cn/browser/twentyeleven/1.6/functions.php#L123

    Thread Starter invaderB

    (@invaderb)

    Hey Guys,

    Thanks for the responses!

    http://quirm.net/2011/09/18/resize-the-header-in-a-twenty-eleven-child-theme/

    ^ I tried this and it either caused a server error or didn’t make any changes at all
    I went through everything they suggested in that post and every one returned errors in the debug mode

    Paul that’s what I thought but if you look on line 120 and 121 it’s defining the height and width there but changing it makes no effect.

    Just to clarify this is not for the image on the home page that one’s fine, it for the images on the other pages that you set up with a featured image.

    like if you compare the homepage to the contact page it’s cropping the image.

    This is from other thread a while ago. Tested on local dev using WP3.5.1 with 2011 that comes with it.

    Featured image size = 1000×200
    http://i.imgur.com/uQV0zfJ.png

    Featured image size = 1000×150

    twentyeleven wp theme header image

    Thread Starter invaderB

    (@invaderb)

    Mk

    So making it small is based on the image size, or is he defining that in the functions file for either 1000×200 or 1000×150?

    but what about making it larger and not having the images cropped?

    I see now, this set_post_thumbnail_size() in the fucntion is refering to the set width and height.
    http://themes.trac.ww.wp.xz.cn/browser/twentyeleven/1.6/functions.php#L150

    AND

    The call in the header.php for featured image, in case of post/page, is refering to that post thumbnail size.
    http://themes.trac.ww.wp.xz.cn/browser/twentyeleven/1.6/header.php#L99

    So that’s why, in case of post/page, the flexible height will never work if the uploaded image is higher than 288, and will work only if it’s smaller as shown in my previous test.

    To make it always work, we have to overwrite this line in header.php

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

    with this

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

    The above will work if you upload exact 1000×400.

    If you want WP to crop it in case of image upload is bigger than 1000×400, you have to put this in child theme function (and no need to do anything in header.php)

    add_action( 'after_setup_theme', 'child_twentyeleven_setup', 11 );
    
    function child_twentyeleven_setup() {
    	add_filter( 'twentyeleven_header_image_height', 'my_header_image_height');
    	set_post_thumbnail_size( 1000, 400, true );
    }
    
    function my_header_image_height($height) {
    	return 400;
    }
    Thread Starter invaderB

    (@invaderb)

    Paul, you are fantastic thank you very much!

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Twenty Eleven V1.6 theme help’ is closed to new replies.