[wp-trac] [WordPress Trac] #27229: Display image file size in media uploader when uploaded
WordPress Trac
noreply at wordpress.org
Sat Mar 1 21:13:58 UTC 2014
#27229: Display image file size in media uploader when uploaded
----------------------------------------+---------------------------------
Reporter: noumaan | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: Future Release
Component: Media | Version: 3.5
Severity: normal | Resolution:
Keywords: needs-patch good-first-bug | Focuses: ui, administration
----------------------------------------+---------------------------------
Comment (by DrewAPicture):
Replying to [comment:2 QasAshraf]:
> Hi, I'm a newcomer looking to contribute. I've been having a look at
what changes would need to be made to implement this new feature.
Great, glad to have you :)
> I can't see how to add an extra instance variable to the Attachment
model, but I think you'd have to add an extra instance variable which
returned the file size for each image. If it's not already implicitly
known, I'm guessing if we already have the filename then we could use the
`filesize($filename)` function to get the size of the file.
You might take a look at how the filesize is derived for use in the
attachment meta box on the attachment editing screen -- the source for
`attachment_submitbox_metadata()` is a good starting place. You'll notice
the 'filesize' key isn't always set as part of the array returned by
`wp_get_attachment_metadata()`, so that's a case that'll need to be
accounted for.
Also, take a look at `wp_prepare_attachment_for_js()`, which is where the
filesize value would be passed to the media template, I'd think as part of
the `$meta` array.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27229#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list