admin管理员组文章数量:1431721
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,
)));
本文标签: customizationSet custom banner image size with wpcustomize
版权声明:本文标题:customization - Set custom banner image size with wp_customize 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745583588a2664763.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论