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');
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');
Share
Improve this question
edited Apr 16, 2019 at 14:40
JakePowell
asked Apr 13, 2019 at 9:23
JakePowellJakePowell
431 silver badge10 bronze badges
1 Answer
Reset to default 0Turns out it's fairly straightforward, just a case of knowing what to search for
https://codex.wordpress/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,
)));