Support » Fixing WordPress » WP_Customize_Cropped_Image_Control, flex_width, flex_height

  • WebTrooper

    (@webtrooper)



    I’m running into two issues with using flex_height and flex_width, which are probably related. In the following code I have both flex_width and flex_height set to false, which is also the default.

    $wp_customize->add_setting(‘cropped_image_1’, array(
    ‘type’ => ‘option’,
    ‘capability’ => ‘edit_theme_options’,
    ‘sanitize_callback’ => ‘absint’
    ));

    $wp_customize->add_control(new WP_Customize_Cropped_Image_Control($wp_customize,
    ‘bc_cropped_image_1’, array(
    ‘section’ => ‘cropped_images’,
    ‘label’ => ‘Image 1’,
    ‘width’ => 1280,
    ‘height’ => 420,
    ‘flex_width’ => false,
    ‘flex_height’ => false,
    )
    ));

    Issue 1 – I’m still able to change the respective dimensions independently and non-proportionally.

    Issue 2 – When I change the proportions of the cropped image, the resulting image is distorted to fit the properly cropped dimensions.

    In short, if I adjust the crop handles to make a square, the resulting image will be “squished” to the proper size of 1280 x 420.

    This seems like a bug but it’s my first time using WP_Customize_Cropped_Image_Control, so figured I should ask here before submitting a bug report. Any ideas?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Is the image appearing squashed in the customiser, or on the front end? If it’s just appearing wrong on the front end the issue is probably with how you’re outputting the value. How are you doing that?

    WebTrooper

    (@webtrooper)

    It doesn’t just appear squashed, the image actually is squashed.

    Since posting this I also tried with the standard custom header and it does the same thing — with flex-height and flex-width set to false I can still change the height and width independently, and the resulting image is squashed or stretched to the cropped size. I should not be able to change them independently. They should always remain proportional.

    WebTrooper

    (@webtrooper)

    If anybody needs to know, this is a bug introduced in version 4.9

    It appears to be caused by code changes to make the resizer keep aspect ration when dragging the cropper while pressing the [Shift] key. I submitted an bug report and it’s being looked into.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WP_Customize_Cropped_Image_Control, flex_width, flex_height’ is closed to new replies.