您可能正在寻找WP_Customize_Cropped_Image_Control
其中width
和height
参数(以及flex_width
和flex_height
). 当您在自定义程序中选择图像时,这将为您显示图像尺寸。例如refer to how the Custom Logo control is registered in core:
$wp_customize->add_control( new WP_Customize_Cropped_Image_Control( $wp_customize, \'custom_logo\', array(
\'label\' => __( \'Logo\' ),
\'section\' => \'title_tagline\',
\'priority\' => 8,
\'height\' => $custom_logo_args[0][\'height\'],
\'width\' => $custom_logo_args[0][\'width\'],
\'flex_height\' => $custom_logo_args[0][\'flex-height\'],
\'flex_width\' => $custom_logo_args[0][\'flex-width\'],
\'button_labels\' => array(
\'select\' => __( \'Select logo\' ),
\'change\' => __( \'Change logo\' ),
\'remove\' => __( \'Remove\' ),
\'default\' => __( \'Default\' ),
\'placeholder\' => __( \'No logo selected\' ),
\'frame_title\' => __( \'Select logo\' ),
\'frame_button\' => __( \'Choose logo\' ),
),
) ) );