Support » Themes and Templates » Twenty Thirteen » Header image isn't responsive

  • Resolved cadfile

    (@cadfile)


    I want to convert my child theme to use Twenty Thirteen as a base but I noticed that the header image isn’t responsive to screen size as rest of page is.

    I understand the developers still think of the header as background art but some like me use it the old school way for a fancy title image for my blog.

    It would be real nice to have away for the header image to scale like the one in Twenty Twelve did.

    Any suggestions or plugins that will do that?

Viewing 15 replies - 1 through 15 (of 27 total)
  • That was my first thought after observing the new default theme. I’m asking, too. How would we create responsive header graphics? I certainly don’t want the central 20% of the header to be the main focus of my header if it’s on a phone at 320px wide. The remaining 80% becomes unseen. Only wider screens truly see it all.

    If you want to have a go at hacking this then here’s something to get you started.

    Create a child theme as per the guidelines here: http://codex.wordpress.org/Child_Themes

    Add a folder in called inc and copy over the custom-header.php

    Create a functions.php and include the custom-header.php as follow.

    require get_stylesheet_directory() . ‘/inc/custom-header.php’;

    Edit custom-header.php @ line 99 where it reads background-size: 1600 auto; replace with background-size: 100% 100%;

    Then after the closing } @ line 100 add the following CSS properties

    @media (max-width: 643px) {
    	.site-header {
    	    background-size: 100% 60%;
    	}
    }

    At this point if you activate your child theme you should have a somewhat responsive header.

    You’ll have to tweak the @media properties to suit your need and add in different breakpoints in the same manner.

    For a demo see: http://wpchildthemes.info/2013flexheader/
    You can also download the child theme from there.

    Enjoy ๐Ÿ™‚
    Zulf

    That is one way to do it but seems not to address the way 2012 handled it. Here is how 2012 handled the header image:

    <?php $header_image = get_header_image();
    		if ( ! empty( $header_image ) ) : ?>
    			<a href="<?php echo esc_url( home_url( '/' ) ); ?>"><img src="<?php echo esc_url( $header_image ); ?>" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" /></a>
    		<?php endif; ?>

    Then in css “header-image” class was under the media section with width 100% and height auto

    So I’ll try to either make the current code work or hack it back to how 2012 did it.

    The problem there with width: 100% height: auto; is that the image get reduced much faster where else with background-size: 100% 100%; you have full control over the reduction ratio using @media parameters.

    Besides, you’ll need to strip out the styles from the custom-header.php as they a fired after the style.css and will always override your styles if left in.

    I think that’s a bit too much work when you already have the function working for you and all you need do is tweak and extend ๐Ÿ™‚

    Do let us know how it goes though as all avenues must be considered in order to get the best results ๐Ÿ™‚

    I tried the function route and got the “can’t re-declare function” error and don’t know enough to get around that.

    I’m not looking for a pretty solution just a functional one for now so I ended up just doing a basic css line:

    .site-header {
    	background-size: 100% auto !important;
    }

    That did work while not having to change a core file which I would have done if the css didn’t work.

    I want the image to reduce as the screen reduces I could probably do the 100% auto in a media call but until I learn it this will have to do.

    Oh OK, that’s understandable ๐Ÿ™‚

    I perhaps should have mentioned the need to rename the function but neglected that and assumed everyone will know – silly mistakes we developers make.

    I’ll probably go play with this a bit more and see how it all pans out but I’m still hopeful that the team will sort it out so that we don’t have to hack anything ๐Ÿ™‚

    I am stuck with this. While adding

    .site-header {
    background-size: 100% auto !important;
    }

    works to make it responsive it adds a huge amount of space on the mobile phone under the image.

    I ended up making that element:

    .site-header {
    background-size: 100% 100% !important;
    }

    Making the height 100% seems to reduce the space at the bottom more than set at auto. On my child theme there was no space between the header image and the nav bar with both set for 100%

    There will be some overlap where the nav bar overlaps the bottom of the header image by a few pxs but nothing you can’t fix by editing the header image

    Hi!
    Feel like a mooch here begging for assistance but anyway:
    Iยดm not that good att coding and would really like to make the header on my twentythirteen themed blogg responsive.

    I would much appreciate if you gyus could help me with some more specific or ready coding samples and what to put where in the WP-installation.

    Please?

    Hi

    Zulfikar, I also dont know what you mean by renaming the function. What do you mean by that? I’m also getting the “can’t re-declare function” error that CADFILE got…

    OK Nevermind I figured out the renaming of the functions. In the custom header file you just have to rename all the functions. Did that, but don’t see a change in my site.

    Also, since it’s the same topic, is it fine that I’m posting here? I don’t see the point in starting my own thread if it is the same topic?

    It would be ideal to start a new topic as this one has been marked as resolved and therefore won’t get much attention from willing helpers ๐Ÿ™‚

    i have 2013 with child already created. my header is a picture of me and my partner on the right side with words and opt in form on left. (see http://www.amberandsteph.com) on laptop looks fine. on a tablet/mobile it cuts me off but if i add a mobile responsive plugin it totally takes header off. i must have opt in form and image showing on mobile/tablet. do i just add code below to my child’s style.css fine?:

    .site-header {
    background-size: 100% 100% !important;
    }

    i don’t want to take chances with coding the functions.php as i recently caused the “white screen of death” and had to hire someone to fix it for me.

    when viewing on mobile/tablet, i want it to look like this person’s site http://www.marieforleo.com

    Yes add the code yo your child theme’s css file. You won’t get the white screen of death if you mess up.

    I’m not sure how your opt-in form will act since it is an overlay (not part of the image).

    Sounds like you might want to look into having a separate theme for mobile screens rather than squeezing your desktop version into a small screen.

    I pasted this at the bottom of the child’s css and nothing happened.

    .site-header {
    background-size: 100% 100% !important;
    }

    any other suggestions?

Viewing 15 replies - 1 through 15 (of 27 total)
  • The topic ‘Header image isn't responsive’ is closed to new replies.