[wp-trac] [WordPress Trac] #59684: 'filesize' metadata not updated after resizing media

WordPress Trac noreply at wordpress.org
Wed Sep 4 16:32:33 UTC 2024


#59684: 'filesize' metadata not updated after resizing media
----------------------------------------+-----------------------
 Reporter:  vertisoft                   |       Owner:  antpb
     Type:  defect (bug)                |      Status:  assigned
 Priority:  normal                      |   Milestone:  6.7
Component:  Media                       |     Version:  6.3.3
 Severity:  minor                       |  Resolution:
 Keywords:  has-testing-info has-patch  |     Focuses:
----------------------------------------+-----------------------

Old description:

> It seems like WordPress does not update the 'filesize' metadata after an
> image is modified through the media library. The details panel in the
> media library displays the original file size instead of the 'new' file
> size.
>
> === Environment
>
> - WordPress: 6.3.3-alpha-56924
> - PHP: 8.2.10
> - Server: Apache
> - Database: mysqli (Server: 5.7.31 / Client: mysqlnd 8.2.10)
> - Browser: Chrome 118.0.0.0 (Windows 10/11)
> - MU-Plugins: None activated
> - Plugins:
>     - WordPress Beta Tester 3.5.4
>
> The following optional modules are not currently installed on our server:
>
> - exif
> - fileinfo
> - imagick
>
> === Steps to Reproduce
>
> 1. Upload a new image in the media library
> 2. Note the file size (ie. 22 KB)
> 3. Resize the image by clicking on 'Edit Image', then 'Scale Image' (in
> my test case, I resized the image from 1920x1080 to 200x113)
> 4. Click 'Update'
> 5. The 'Dimensions' field is correctly updated, but 'File size' remains
> the same (22 KB)
>
> === Expected Results
>
> The 'File size' should display the new file size (ie. 3.3 KB)
>
> === Actual Results
>
> The 'File size' field displays the size of the original image, before it
> was resized.
>
> Here is the value of the '_wp_attachment_metadata' field in the database
> after the media is resized:
>
> {{{
> a:6:{s:5:"width";i:200;s:6:"height";i:113;s:4:"file";s:31:"2023/10/Test-e1697729884174.png";s:8:"filesize";i:22990;s:5:"sizes";a:5:{s:6:"medium";a:5:{s:4:"file";s:16
> :"Test-300x169.png";s:5:"width";i:300;s:6:"height";i:169;s:9:"mime-
> type";s:9:"image/png";s:8:"filesize";i:4852;}s:5:"large";a:5:{s:4:"file";s:17
> :"Test-1024x576.png";s:5:"width";i:1024;s:6:"height";i:576;s:9:"mime-
> type";s:9:"image/png";s:8:"filesize";i:18748;}s:9:"thumbnail";a:5:{s:4:"file";s:16
> :"Test-150x150.png";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-
> type";s:9:"image/png";s:8:"filesize";i:3006;}s:12:"medium_large";a:5:{s:4:"file";s:16
> :"Test-768x432.png";s:5:"width";i:768;s:6:"height";i:432;s:9:"mime-
> type";s:9:"image/png";s:8:"filesize";i:13044;}s:9:"1536x1536";a:5:{s:4:"file";s:17
> :"Test-1536x864.png";s:5:"width";i:1536;s:6:"height";i:864;s:9:"mime-
> type";s:9:"image/png";s:8:"filesize";i:30857;}}s:10:"image_meta";a:12:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";s:11:"orientation";s:1:"0";s:8:"keywords";a:0:{}}}
> }}}
>
> The "filesize" metadata has the value '22990' instead of '3033'.

New description:

 It seems like WordPress does not update the 'filesize' metadata after an
 image is modified through the media library. The details panel in the
 media library displays the original file size instead of the 'new' file
 size.

 === Environment

 - WordPress: 6.3.3-alpha-56924
 - PHP: 8.2.10
 - Server: Apache
 - Database: mysqli (Server: 5.7.31 / Client: mysqlnd 8.2.10)
 - Browser: Chrome 118.0.0.0 (Windows 10/11)
 - MU-Plugins: None activated
 - Plugins:
     - WordPress Beta Tester 3.5.4

 The following optional modules are not currently installed on our server:

 - exif
 - fileinfo
 - imagick

 === Steps to Reproduce

 1. Upload a new image in the media library
 2. Switch to the 'list' view in the media library to test the attachment
 page.
 3. Note the file size (ie. 22 KB)
 4. Resize the image by clicking on 'Edit Image', then 'Scale Image' (in my
 test case, I resized the image from 1920x1080 to 200x113)
 5. Click 'Update'
 6. The 'Dimensions' field is correctly updated, but 'File size' remains
 the same (22 KB)

 === Expected Results

 The 'File size' should display the new file size (ie. 3.3 KB)

 === Actual Results

 The 'File size' field displays the size of the original image, before it
 was resized.

 Here is the value of the '_wp_attachment_metadata' field in the database
 after the media is resized:

 {{{
 a:6:{s:5:"width";i:200;s:6:"height";i:113;s:4:"file";s:31:"2023/10/Test-e1697729884174.png";s:8:"filesize";i:22990;s:5:"sizes";a:5:{s:6:"medium";a:5:{s:4:"file";s:16
 :"Test-300x169.png";s:5:"width";i:300;s:6:"height";i:169;s:9:"mime-
 type";s:9:"image/png";s:8:"filesize";i:4852;}s:5:"large";a:5:{s:4:"file";s:17
 :"Test-1024x576.png";s:5:"width";i:1024;s:6:"height";i:576;s:9:"mime-
 type";s:9:"image/png";s:8:"filesize";i:18748;}s:9:"thumbnail";a:5:{s:4:"file";s:16
 :"Test-150x150.png";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-
 type";s:9:"image/png";s:8:"filesize";i:3006;}s:12:"medium_large";a:5:{s:4:"file";s:16
 :"Test-768x432.png";s:5:"width";i:768;s:6:"height";i:432;s:9:"mime-
 type";s:9:"image/png";s:8:"filesize";i:13044;}s:9:"1536x1536";a:5:{s:4:"file";s:17
 :"Test-1536x864.png";s:5:"width";i:1536;s:6:"height";i:864;s:9:"mime-
 type";s:9:"image/png";s:8:"filesize";i:30857;}}s:10:"image_meta";a:12:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";s:11:"orientation";s:1:"0";s:8:"keywords";a:0:{}}}
 }}}

 The "filesize" metadata has the value '22990' instead of '3033'.

--

Comment (by joedolson):

 Updating the description's reproduction steps to specify that this test
 needs to be performed in the attachment details page, not in the media
 modal. Unfortunately, the tests by @rajinsharwar are not valid, because
 they were performed in the media modal.

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


More information about the wp-trac mailing list