WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the following code to allow a user to upload a custom image (in addition to header image) through the customizer. Is there a way to crop the image when displaying it?

$wp_customize->add_setting( 'intro-img',
array (
'default' => 'http://example.com/image.png',

new WP_Customize_Image_Control(
        'label' => 'Intro Image',
        'section' => 'section_one',
        'settings' => 'intro-img'


and displaying with:

<?php echo get_theme_mod( 'intro-img', 'http://example.com/image.png' ); ?>
share|improve this question

With your method it would be very tricky, if it's possible at all. What you could do is use a custom header with flexible dimensions. That would allow the user to upload the header image and then crop it how ever they needed easily.

// Register Theme Features
function custom_theme_features()  {

// Add theme support for Custom Header
$header_args = array(
    'default-image'          => 'http://example.com/image.png',
    'width'                  => 0,
    'height'                 => 0,
    'flex-width'             => true,
    'flex-height'            => true,
    'random-default'         => false,
    'header-text'            => false,
    'default-text-color'     => '',
    'uploads'                => true,

add_theme_support( 'custom-header', $header_args );

// Hook into the 'after_setup_theme' action
add_action( 'after_setup_theme', 'custom_theme_features' );
share|improve this answer

Your Answer


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.