• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Uploading Images to Theme Directory via Theme Customizer

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Uploading Images to Theme Directory via Theme Customizer

This topic is: not resolved

Tagged: theme customizer, WP_Customize, WP_Customize_Image_Control

  • This topic has 2 replies, 2 voices, and was last updated 10 years, 8 months ago by Brad West.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • February 16, 2015 at 8:36 pm #141063
    Brad West
    Member

    I'd like to use the Theme Customizer to move an image into my themes /images directory and rename it to bg.jpg. I've seen this done on the Parallax theme, but I can't replicate it in my local development environment.

    The code I've used does save an image in the Theme Customizer, but saves it in the uploads folder and doesn't change the name.

    add_action( 'customize_register', 'home_background_customizer' );
    function home_background_customizer( $wp_customize ) {
    
      $wp_customize->add_section(
        'home_background_image', array(
          'title' => 'Homepage Background Image',
          'description' => 'Add an image to the homepage.',
          'priority' => 30,
        )
      );
    
      $wp_customize->add_setting(
        'img-upload', array(
          'default' => 'bg.jpg',
        )
      );
    
      $wp_customize->add_control(
        new WP_Customize_Image_Control(
          $wp_customize,
          'img-upload', array(
            'label' => 'Upload Image',
            'section' => 'home_background_image',
            'settings' => 'img-upload'
          )
        )
      );
    
    }

    Here's the code from the Parallax Pro theme for uploading three images to be used as section backgrounds on the homepage:

    class Child_Parallax_Image_Control extends WP_Customize_Image_Control {
    
      public function __construct( $manager, $id, $args ) {
        $this->statuses = array( '' => __( 'No Image', 'parallax' ) );
    
        parent::__construct( $manager, $id, $args );
    
        $this->add_tab( 'upload-new', __( 'Upload New', 'parallax' ), array( $this, 'tab_upload_new' ) );
        $this->add_tab( 'uploaded',   __( 'Uploaded', 'parallax' ),   array( $this, 'tab_uploaded' ) );
    
        if ( $this->setting->default )
          $this->add_tab( 'default',  __( 'Default', 'parallax' ),  array( $this, 'tab_default_background' ) );
    
        add_action( 'customize_controls_init', array( $this, 'prepare_control' ), 5 );
      }
    
      public function tab_default_background() {
        $this->print_tab_image( $this->setting->default );
      }
    
    }
    
    global $wp_customize;
    
    $images = apply_filters( 'parallax_images', array( '1', '3', '5' ) );
    
    $wp_customize->add_section( 'parallax-settings', array(
      'title'    => __( 'Background Images', 'parallax' ),
      'priority' => 35,
    ) );
    
    foreach( $images as $image ){
    
      $wp_customize->add_setting( $image .'-image', array(
        'default'  => sprintf( '%s/images/bg-%s.jpg', get_stylesheet_directory_uri(), $image ),
        'type'     => 'option',
      ) );
    
      $wp_customize->add_control( new Child_Parallax_Image_Control( $wp_customize, $image .'-image', array(
        'label'    => sprintf( __( 'Featured Section %s Image:', 'parallax' ), $image ),
        'section'  => 'parallax-settings',
        'settings' => $image .'-image',
        'priority' => $image+1,
      ) ) );
    
    }

    Any ideas on getting the image into the /images directory and renaming it bg.jpg?

    May 7, 2015 at 7:22 pm #150811
    Susan
    Moderator

    As you posted this a while ago, I hope you were able to get your issue resolved. If it is resolved, please mark this thread as “resolved”, so it can be closed.

    If you are still having issues, report back here, and I will try to escalate.

    May 7, 2015 at 7:56 pm #150836
    Brad West
    Member

    Hi Susan,
    I am still working on this. It's been pushed to the back burner since it's proving difficult. I've been digging through some tutorials on the Customizer trying to better understand how it works. But so far, no luck.

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble