Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#34851 closed defect (bug) (fixed)

Flex Sizes In WP_Customize_Cropped_Image_Control Not Working

Reported by: stephenpunwasi's profile stephen.punwasi Owned by: westonruter's profile westonruter
Milestone: 4.5 Priority: normal
Severity: normal Version: 4.3.1
Component: Customize Keywords: has-patch commit
Focuses: Cc:

Description

Doesn't appear that the "flex_width" or "flex_height" are working when set to true. Anyone else having this problem?

Attachments (2)

media-views.diff (592 bytes) - added by coreymckrill4ttf 10 years ago.
34851.diff (1.5 KB) - added by westonruter 10 years ago.

Download all attachments as: .zip

Change History (12)

#1 in reply to: ↑ description @stephen.punwasi
10 years ago

<?php
    $wp_customize->add_setting('cropped_image');
     $wp_customize->add_control( new WP_Customize_Cropped_Image_Control( $wp_customize, 'cropped_image', array(
    'section'     => 'title_tagline',
    'label'       => __( 'Croppable Image' ),
    'flex_width'  => true,
    'flex_height' => true,
    'width'       => 920,
    'height'      => 80,
        ) ) );

Code example tried with the twentyfifteen, just in cast I'm missing something.

#2 @coreymckrill4ttf
10 years ago

I'm seeing this in 4.4.1 as well. It looks like this is happening because when the script submits the parameters for executing the crop, it sets the destination file dimensions to be whatever the "suggested" width and height are in the Customizer's control definition.

cropDetails.dst_width  = control.params.width;
cropDetails.dst_height = control.params.height;

Changing dst_width and dst_height to equal the normal width and height values in the cropDetails object appears to fix the problem, because then the destination file has the same dimensions as the area selected for the crop. That may not always be the desired outcome, if the cropped file is expected to have a min/max dimension limit, but in that case, it seems like there should probably be other parameters for the WP_Customize_Cropped_Image_Control to specify this behavior.

#3 follow-up: @coreymckrill4ttf
10 years ago

  • Keywords has-patch needs-testing added

#4 in reply to: ↑ 3 @stephen.punwasi
10 years ago

Replying to coreymckrill4ttf:

Sweet, good catch.

This ticket was mentioned in Slack in #core by chriscct7. View the logs.


10 years ago

@westonruter
10 years ago

#6 @westonruter
10 years ago

What about 34851.diff, as a subset of a patch from #36255?

#7 @coreymckrill4ttf
10 years ago

@westonruter works for me!

#8 @celloexpressions
10 years ago

This is removed from the latest patch on #36255, so should be good to go here.

#9 @westonruter
10 years ago

  • Keywords commit added; needs-testing removed
  • Milestone changed from Awaiting Review to 4.5
  • Owner set to westonruter
  • Status changed from new to accepted

#10 @westonruter
10 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 37042:

Customize: Add support for flex sizes in CustomizeImageCropper.

Ensures that $flex_width and $flex_height as specified on WP_Customize_Cropped_Image_Control will be honored when a crop is saved.

See #36255.
Fixes #34851.

Note: See TracTickets for help on using tickets.