[wp-trac] [WordPress Trac] #50384: @getimagesize bug for some images: Returns empty

WordPress Trac noreply at wordpress.org
Sat Jun 13 11:48:11 UTC 2020


#50384: @getimagesize bug for some images: Returns empty
--------------------------+------------------------------
 Reporter:  samwebdev     |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Media         |     Version:  5.4.1
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------
Changes (by SergeyBiryukov):

 * component:  General => Media


Old description:

> Hello,
>
> Stumbled upon a bug at @getimagesize, which causes image generation to
> fail.
>
> To replicate:
>
> upload
>
> https://n11scdn1.akamaized.net/a1/1024/elektronik/access-point-router
> /xiaomi-mi-wifi-pro-sinyal-yakinlastirici-
> guclendirici-300-mbps__0804220795448321.jpg
>
> 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

New description:

 Hello,

 Stumbled upon a bug at `@getimagesize`, which causes image generation to
 fail.

 To replicate:

 upload

 https://n11scdn1.akamaized.net/a1/1024/elektronik/access-point-router
 /xiaomi-mi-wifi-pro-sinyal-yakinlastirici-
 guclendirici-300-mbps__0804220795448321.jpg

 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

--

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50384#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list