0

I've set the banner image of my site to be customizable through appearance -> customize.

I'd like to adjust the image size and crop aspect ratio of the customizer, as it's still set to a thumbnail square, 150px by 150px and the banner image turns out blurry. Is this possible?

This is the code in functions.php

function tyc_banner_image($wp_customize) {
    $wp_customize->add_section('tyc_banner_image-section', array(
        'title' => 'Banner Image'
    ));

    $wp_customize->add_setting('tyc_banner_image-display', array(
        'default' => 'No'
    ));


    $wp_customize->add_setting('tyc_banner_image-image');

    $wp_customize->add_control( new WP_Customize_Cropped_Image_Control($wp_customize, 'tyc_banner_image-control', array(
            'label' => 'Image',
            'section' => 'tyc_banner_image-section',
            'settings' => 'tyc_banner_image-image',

        )));
}

add_action('customize_register', 'tyc_banner_image');

enter image description here

0

Turns out it's fairly straightforward, just a case of knowing what to search for

https://codex.wordpress.org/Class_Reference/WP_Customize_Manager

In my tyc_banner_image function I added the last four arguments below.

$wp_customize->add_control( new WP_Customize_Cropped_Image_Control($wp_customize, 'tyc_banner_image-control', array(
            'label' => 'Image',
            'section' => 'tyc_banner_image-section',
            'settings' => 'tyc_banner_image-image',
            'flex_width'  => true,
            'flex_height' => true,
            'width'       => 1920,
            'height'      => 500,
        )));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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