Title: Code for WP &#8220;file size&#8221; Field
Last modified: April 11, 2017

---

# Code for WP “file size” Field

 *  Resolved [Ellsinore](https://wordpress.org/support/users/ellsinore/)
 * (@ellsinore)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/code-for-wp-file-size-field/)
 * Hi, David!
 * For my media library ([http://cousin-collector.com/blog/?page_id=690](http://cousin-collector.com/blog/?page_id=690)),
   I’ve been able to use either IPTC metadata or the WP media item information for
   my listings. The one thing that’s evading me is the file size. I see that WP 
   lists that information, but I don’t know the code to access it, so it has to 
   get it from the photo or PDF itself each time the page is loaded.
 * For instance, the first PDF in the list has this line:
 * **Uploaded:** 12 March 2017 **Modified:** 12 March 2017 (293.0 KB)
 * I’m using:
    `{+file_size,kbmb( 1024 , ' KB', ' MB', 1 )+}`
 * But IIRC it would be more efficient to access the WP field for this? Such as 
   with the Description field?
 * `{+description+}`
 * Thanks!
 * Kris

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [David Lingren](https://wordpress.org/support/users/dglingren/)
 * (@dglingren)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/code-for-wp-file-size-field/#post-9019920)
 * Thanks for an interesting question. You wrote “**_I see that WP lists that information…_**”
   I assume you mean that the file size appears, for example, in the “Save” metabox
   at the upper-right part of the Media/Edit Media admin screen; is that right?
 * As far as I know, WordPress does not store the file size anywhere in the database,
   as it does for fields like Description. I did a quick search of the WordPress
   code and found many places where the PHP `filesize()` function is used to find
   the file size. This is the same function MLA uses to populate the `{+file_size
   +}` data source.
 * You could map this value to a custom field, but I don’t think that is any more
   efficient than accessing the value directly when you need it. If `filesize()`
   is good enough for WordPress, it should suffice for your application as well.
 * I am marking this topic resolved, but please update it if you have further questions
   about finding the file size for your application.
 *  Thread Starter [Ellsinore](https://wordpress.org/support/users/ellsinore/)
 * (@ellsinore)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/code-for-wp-file-size-field/#post-9021597)
 * Hi, David!
 * Just for archival purposes, yes, this is where I’m finding the size information
   in the WP media admin screen:
 * ![Screenshot](https://i0.wp.com/cousin-collector.com/images/Image.png)
 * If `filesize()` is good enough for WP, it’s good enough for me.
 * Thanks! 🙂
 * Kris

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Code for WP “file size” Field’ is closed to new replies.

 * ![](https://ps.w.org/media-library-assistant/assets/icon-256x256.png?rev=973502)
 * [Media Library Assistant](https://wordpress.org/plugins/media-library-assistant/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/media-library-assistant/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/media-library-assistant/)
 * [Active Topics](https://wordpress.org/support/plugin/media-library-assistant/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/media-library-assistant/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/media-library-assistant/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Ellsinore](https://wordpress.org/support/users/ellsinore/)
 * Last activity: [9 years, 1 month ago](https://wordpress.org/support/topic/code-for-wp-file-size-field/#post-9021597)
 * Status: resolved