$("#element").filesize()
$(".fs").filesize()
> $.fn.filesize._humanize(2000)
> "1.95 kilobytes"
- 1999 becomes 1.95 kB
- 5000000 becomes 488.28 kB
- 6000000000 becomes 5.59 GB
See demo/index.html for more examples.
To use as a Helper in Ember:
- bower install jquery-filesize
- Add the script in the html
- Add a helper in Ember
Ember.Handlebars.helper 'bytes', (value, options) ->
humanReadable = $.fn.filesize._humanize(Handlebars.Utils.escapeExpression(value), {abbr: true})
return new Handlebars.SafeString('<span>' + humanReadable + '</span>')
- fork the repo
- npm install
- grunt (which tests and packages)