如何在WordPress函数上增加宽度和高度(分辨率)?

时间:2017-04-25 作者:M.Nadeem

如何添加自定义宽度(&A);高度到我们的自定义图像上载程序

function clientPic6( $wp_customize ) {   
    $wp_customize->add_setting( \'client_background_img_6\'); // Add setting for logo uploader
    // Add control for logo uploader (actual uploader)
    $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, \'m1_client_img_6\', array(
        \'label\'    => __( \'Client Image\', \'m2_C6\' ),
        \'section\'  => \'custom_client_block\',
        \'settings\' => \'client_background_img_6\',
    ) ) );
}
add_action( \'customize_register\', \'clientPic6\' );

1 个回复
SO网友:Weston Ruter

您可能正在寻找WP_Customize_Cropped_Image_Control 其中widthheight 参数(以及flex_widthflex_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\' ),
    ),
) ) );

相关推荐