【发布时间】:2016-12-17 02:02:51
【问题描述】:
我在定制器中遇到了WP_Customize_Cropped_Image_Control 的问题。我设置的默认图像不会显示在您上传的定制器的侧窗格中,当我上传新图像时,它只会输出一个数字,假设是图像 ID。当我将WP_Customize_Cropped_Image_Control 更改为WP_Customize_Image_Control 时,一切正常。默认图像和上传的图像都显示在定制器和预览窗口中。
是否有不同的方式来设置/显示定制器中默认裁剪图像的默认图像?
这是我在customizer.php 中的代码:
$wp_customize->add_setting( 'bio_image', array(
'default' => get_template_directory_uri() . '/images/default.jpg',
'transport' => 'postMessage'
) );
$wp_customize->add_control( new WP_Customize_Cropped_Image_Control( $wp_customize, 'bio_image', array(
'label' => __( 'Image', 'myTheme' ),
'flex_width' => false,
'flex_height' => false,
'width' => 330,
'height' => 330,
'settings' => 'bio_image'
) ) );
这是我在customizer.js 中的代码:
wp.customize( 'bio_image', function( value ) {
value.bind( function( newval ) {
$('#bio-image').attr( 'src', newval );
} );
} );
这是我的模板文件中的代码:
<img id="bio-image" src="<?php echo get_theme_mod( 'bio_image' , get_template_directory_uri().'/images/default.jpg' ); ?>">
【问题讨论】:
-
面临同样的问题。你找到答案了吗?
标签: javascript php jquery wordpress