Making WordPress.org

Opened 2 months ago

Closed 2 months ago

#7904 closed defect (bug) (fixed)

Photo dimensions incorrectly validated

Reported by: benniledl's profile benniledl Owned by: coffee2code's profile coffee2code
Milestone: Priority: normal
Component: Photo Directory Keywords: needs-patch
Cc:

Description

wp_get_attachment_metadata() retrieves the metadata of the scaled version of uploaded images, not the original. https://github.com/WordPress/wordpress.org/blob/c4d8d5902c132eb79729c3473d94426926b16dc0/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/uploads.php#L693

Thus even tho the original does meet the 2000px minimum requirement, the scaled version might not and thus the image is rejected.

I tested this by installing the plugin wp-frontend-uploader on a test site, uploading a photo, and checking the metadata with wp_get_attachment_metadata
The metadata returned dimensions of the *-scaled.jpg version instead of the original.

Change History (2)

#1 @benniledl
2 months ago

If the uploaded image exceeds 2560px in either dimension, WordPress scales it down proportionally so that the largest side is exactly 2560px.

An image that is 2592px wide and 4608px high will be shrunk down by about 44.5%

This will leave the wide side with only 1440px.

#2 @coffee2code
2 months ago

  • Owner set to coffee2code
  • Resolution set to fixed
  • Status changed from new to closed

In 14386:

Photo Directory, Uploads: Ensure override of 'big_image_size_threshold' takes precedence.

The parent theme of the new theme sets a threshold of 3200, which caused a scaled image to be used and potentially also return an insufficient dimensions error.

Props nilovelez, benniledl, jeffpaul, coffee2code.
Fixes #7854, #7888, #7904.

Note: See TracTickets for help on using tickets.