Simple file icons that use the Rails Asset Pipeline.
Add this line to your application's Gemfile:
gem 'rails-file-icons'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rails-file-icons
- classic
- high-contrast
- square-o
- vivid
- 'square-o' is default theme
- Specify/set default theme by
ENV['DEFAULT_FILE_ICON_STYLE']
e.g.ENV['DEFAULT_FILE_ICON_STYLE'] = 'vivid'
- Theme name can also be passed as second argument to the method call. Example below in usage section
Render a file icon for a given filename in a view.
Use default icon theme
<%= image_tag Icon.for_filename('myfile.jpg') %>
Specify icon theme
<%= image_tag Icon.for_filename('myfile.jpg', 'vivid') %>
Get the image path for a given file extension. (leading dot is irrelevant)
Icon.for_ext '.jpg'
=> 'fileicons/classic/jpg.svg'
Icon.for_ext 'gif'
=> 'fileicons/classic/gif.svg'
Icon.for_ext('gif', 'vivid')
=> 'fileicons/vivid/gif.svg'
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request