The other day I got an interesting support thread for Easy Digital Downloads, asking for the list of files, and their sizes be displayed when viewing a product. Being that I only use it to sell WordPress plugins, it seemed pretty minor, but if you were dealing with larger Audio/Video files, or your consumers used their mobile devices frequently, I could see how this would be useful. So I put together a quick, single file, plugin that is now available in the EDD Library Repo on Github.

First, here’s the primary function that is run:

Now, a quick overview. Basically what we’re doing is looking for all the uploaded media items attached as ‘Downloads’ to this product. Once we get them, we’re iterating through them. You see this in the line

After that we do some setup, only wanting 2 decimal places, setting up the title of the list (following the numeric localization method), and you’ll notice that odd variable BKMGTP. What is this? Well it’s used to make the output of the size calculation human readable. It’s for “Bytes, Kilobytes, Megabytes, Gigabytes, Terabytes, and Petabytes”. I’ve never seen a use case of someone selling Tera/Petabyte files on EDD, but who am I to judge.

After that, a little loop to run each calculation by powers of 1024, and we’re good to go!

You can go grab the full plugin-ready file here.

Image credit(CC): John Trainor

Post Promoter Pro

Posted by Chris Klosowski

Hi, I'm Chris Klosowski. Currently I am a Lead Developer of Easy Digital Downloads, where we build the easiest way to sell digital products with WordPress. I am also the person behind Post Promoter Pro, the most effective way to promote your WordPress Content.


  1. […] EDD? Here’s a very handy snippet to show file sizes for downloads on the product pages. Sumobi also released a free extension for add-to-cart redirects on […]


    1. This is a great suggestion, thanks!


  2. Hi Chris, thanks for the code! I’ve added this to functions.php and then on my product page I’ve added;

    $post = get_post();
    edd_ck_show_file_sizes( $post->ID );

    which is almost working. Strangely, if I upload a file with the fes submission form it shows the size as 0.00, but if I upload a file from the WordPress dashboard it seems to show the size correctly. Any idea why this might be? Screenshot;

    Thanks again.



    1. Hi, I am facing the same problem. As I found out, this is all from the fact that the plugin FES does not add parameter ‘attachment_id’ to the table ‘wp_postmeta’ in line ‘edd_download_files’.
      I found the file plugins/edd-fes/classes/fields/multiple_pricing.php
      and in the lines 513 and 523 added: ‘attachment_id’ => fes_get_attachment_id_from_url( $url, $user_id )
      And it all worked)
      But I don’t know if all this is right and there will be no problems in the future …) Thanks


  3. hi, how to show
    file name with extension ?
    name : test size : 39 kb type: zip



Leave a reply

Your email address will not be published. Required fields are marked *