Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.
add_action( 'customize_register', 'boilerplate_customize_register' );
function boilerplate_customize_register($wp_customize) {
    $wp_customize->add_section( 'themename_color_scheme', array(
        'title'          => __( 'Color Scheme (sect!on name)', 'themename' ),
        'description'    => "This changes color scheme",
        'priority'       => 135,
    ));
    $wp_customize->add_setting('themename_theme_options[image_upload_test]', array(
        'default' => 'image.jpg',
        'capability' => 'edit_theme_options',
        'type' => 'option',
    ));
    $wp_customize->add_control( new WP_Customize_Image_Control($wp_customize, 'image_upload_test', array(
        'label' => __('Image Upload Test', 'themename'),
        'section' => 'themename_color_scheme',
        'settings' => 'themename_theme_options[image_upload_test]',
    )));
}

This adds a section in Theme customization page and in it, an image upload dialog. Where does this image go and how can I refer to it?

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

The theme customiser will take the upload and put it in wp-content, but the folder or specific place is irrelevant. If you find yourself using it, you've made a mistake and your code has gone horribly wrong.

To be specific, your option is not referring to an image you uploaded, it is referring to an Attachment, specifically it saves the ID of an attachment.

Attachments are posts of post type 'attachment', they have post content, post parents, titles etc, and when you use the theme customiser to add an image upload the image gets uploaded, an attachment post will be created for it, and the ID of that attachment is then used to refer to the image. The ID is saved as a theme mod.

You can grab the various sizes of the attachment using functions such as wp_get_attachment_url

You can read more about this here:

http://codex.wordpress.org/Function_Reference/wp_get_attachment_url

You'll also find the function get_theme_mod useful:

http://codex.wordpress.org/Function_Reference/get_theme_mod

share|improve this answer
add comment

By default it goes into "wp-content/uploads" and possibly into date organized folders depending on how your site is configured. It is possible to change the default location and it is possible to conditionally change the location-- that is, change the location only for certain uploads.

All that means that it isn't possible to say with certainty because there are unknowns, but start looking in 'uploads', or just upload an image and "View Source" on the page. You can read the URL from the source easily enough.

share|improve this answer
    
Thanks. Also, how would I refer to it (in php)? (without knowing the particular URL) ..like if I wanted to use the uploaded image in my theme's header? –  laggingreflex Nov 3 '12 at 14:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.