Theme Customizer API - Upload new header image (8 posts)

  1. clarklab
    Posted 3 years ago #

    I'm working on a theme framework that'll eventually be managed by secretaries and interns so I'm looking to take advantage of the new Theme Customizer as much as possible. I'm trying to enable custom headers and custom backgrounds, and everything is working perfectly except uploads of custom header images.

    The problem: uploading header images only works via the Appearance > Header screen in the admin. The ability to upload isn't present when inside the theme customizer.

    The annoying part: uploading background images works just fine, in both places.

    Here is the code I used to enable both features:

    $args = array(
    	'flex-width'    => true,
    	'width'         => 960,
    	'flex-height'    => true,
    	'height'        => 200,
    	'default-image' => '',
    	'uploads' => true
    add_theme_support( 'custom-header', $args );
    $defaults = array(
    	'default-color'          => '',
    	'default-image'          => '',
    	'wp-head-callback'       => '',
    	'admin-head-callback'    => '',
    	'admin-preview-callback' => ''
    add_theme_support( 'custom-background', $defaults );

    And here is how the features appear in the theme customizer:


    As you can see, the header image doesn't allow for a new image to be uploaded, only to pick from images previously uploaded. The custom background allows the user to upload just fine.

    Any got any idea what's going on here?

  2. esmi
    Forum Moderator
    Posted 3 years ago #

    The ability to upload isn't present when inside the theme customizer.

    Correct. Bear in mind that the Theme Customizer is still in its infancy, so may not have all of the features that you expected.

    Have you reviewed:

  3. clarklab
    Posted 3 years ago #

    But, but... the backgrounds upload just fine. I've also made my own settings section with an image upload contained. Will I need to avoid the 'core' header feature and write my own? The only difference is the admin screen will disappear, which I wanted to hide anyway.

    I guess I'm just confused why image uploads work everywhere but the header. Is it the cropping?

  4. Bill Erickson
    Posted 3 years ago #

    Here's the relevant ticket: http://core.trac.wordpress.org/ticket/21355

    It looks like header upload WAS in the customizer, but because cropping wasn't there it couldn't enforce the header dimensions. It was pulled in 3.4.2, and will hopefully be added back in 3.5 with cropping.

  5. clarklab
    Posted 3 years ago #

    My timing is always impeccable.

  6. juliedc
    Posted 3 years ago #

    Just upgraded to 3.5 today and now I can upload a header image but it won't appear. Css looks fine. Site with no logo - yikes. Can anyone point me to where I can find a fix?

  7. WPyogi
    Forum Moderator
    Posted 3 years ago #

    @juliedc, per the forum guidelines, if you need help, you should start your own thread rather than tacking on to an old one. Especially since your issue is totally different given that is is a 3.5 upgrade problem.

  8. juliedc
    Posted 3 years ago #

    ok, will do

Topic Closed

This topic has been closed to new replies.

About this Topic