Super simple wrapper for the imgix.net API.
Add this line to your application's Gemfile:
gem 'imgix'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install imgix
Basic configuration in the model (currently only supports :h, :w, :crop, :fit, and :bg)
class User < ActiveRecord::Base
has_imgix_attachment :photo,
:subdomain => "demo",
:prefix => "avatars",
:default => "default.png",
:styles => {
:small => {
:h => 32,
:w => 32,
:crop => "faces",
:fit => "crop"
},
:medium => {
:h => 64,
:w => 64,
:crop => "faces",
:fit => "crop"
},
:large => {
:h => 96,
:w => 96,
:crop => "faces",
:fit => "crop"
}
}
end
Retrieve the original image
@user.photo.url
> "http://demo.imgix.net/avatars/filename.jpg"
Retrieve a specific style
@user.photo.url(:medium)
> "http://demo.imgix.net/avatars/filename.jpg?crop=faces&fit=crop&h=64&w=64"
Generate an image tag
imgix_tag(@user.photo, "medium", :alt => "test photo")
> "<img src="http://demo.imgix.net/avatars/filename.jpg?crop=faces&fit=crop&h=64&w=64" alt="test photo" />"
- 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