Opened 5 years ago
Closed 2 weeks ago
#50384 closed defect (bug) (invalid)
@getimagesize bug for some images: Returns empty
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 5.4.1 |
Component: | Media | Keywords: | reporter-feedback close |
Focuses: | Cc: |
Description (last modified by )
Hello,
Stumbled upon a bug at @getimagesize
, which causes image generation to fail.
To replicate:
upload
The original file will be available in /uploads/ folder; it browse fine in browser. Metadata generation will fail via wp_generate_attachment_metadata, hence thumbnail generations will fail.
Further checking, wp_create_image_subsizes is called, where
$imagesize = @getimagesize( $file );
will try to get the image size, which it returns empty.
if ( empty( $imagesize ) ) { // File is not an image. return array(); }
will return empty array, hence wp_generate_attachment_metadata will save empty metadata, hence any file generation will be cancelled.
Manually setting imagesize where @getimagesize
fails, can confirm metadata generates fine and all file regenarations work.
if ( empty( $imagesize ) ) { $imagesize[0] = 1024; $imagesize[1] = 1024; // File is not an image. // return array(); }
@getimagesize
fails for some files.
Regards,
Sam
Change History (4)
This ticket was mentioned in Slack in #core-media by antpb. View the logs.
3 years ago
#4
@
2 weeks ago
- Keywords close added
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
Thank you for your report. Today, I am going to move this ticket to 'close' with a status of 'invalid', purely to denote that, potentially, what is happening is a variation in use or something else unknown at this time. Currently, it is hard to replicate due to not having more information; should that happen, we can always reopen and adjust the status.
hi @samwebdev ! Thanks for this report. Looking at the function today I notice we are using
wp_getimagesize
which better accounts for edge cases like these. Is it possible for you to test this again using the latest WordPress to ensure this is still happening?Here's a link to the latest version of the code: https://github.com/WordPress/wordpress-develop/blob/a14324ca3af4eeff69406d3e59719a33f055f07e/src/wp-admin/includes/image.php#L237