Make WordPress Core

Opened 12 days ago

Last modified 2 days ago

#43226 new defect (bug)

Crop setting in thumbnails never set when uploading PDF files

Reported by: leemon Owned by:
Milestone: 4.9.5 Priority: normal
Severity: normal Version: 4.7
Component: Media Keywords: needs-patch needs-unit-tests
Focuses: administration Cc:


I don't know if it's specific to my server config but, for some reason, the crop setting in thumbnails is never set when I upload PDF files.

Apparently, the following conditional statement in the /wp-admin/includes/image.php file is never true when it's supposed to run for medium and large thumbnails:


If I remove the conditional statement the crop setting is set for all thumbnails.

I'm using WordPress 4.9.2 with PHP 7.0.27

Attachments (2)

43226.diff (537 bytes) - added by chetan200891 10 days ago.
43226-unit-test.diff (2.0 KB) - added by chetan200891 2 days ago.
Unit test.

Download all attachments as: .zip

Change History (8)

#1 @leemon
12 days ago

If I change the conditional statement to:

if ( 'thumbnail' !== $s ) {
    $sizes[ $s ]['crop'] = get_option( "{$s}_crop" );

it works as expected.

#2 @leemon
11 days ago

  • Keywords dev-feedback added

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

10 days ago

#4 @SergeyBiryukov
10 days ago

  • Keywords needs-patch needs-unit-tests added; dev-feedback removed
  • Milestone changed from Awaiting Review to 4.9.5

Hi @leemon, welcome to WordPress Trac! Thanks for the report.

Yes, the current ! 'thumbnail' === $s condition doesn't appear to work as expected. It's only satisfied if $s is boolean false. It should indeed be 'thumbnail' !== $s.

#5 @SergeyBiryukov
10 days ago

  • Version changed from 4.9.2 to 4.7

Introduced in [38949].

10 days ago

2 days ago

Unit test.

#6 @chetan200891
2 days ago

Attached Unit Test patch 43226-unit-test.diff

The smallest thumbnail size was specifically excluded from forced cropping, but that the patch would fix it so that the other sizes would honor the forced cropping.

Note: See TracTickets for help on using tickets.