Skip to content

Let's you easily interface with Resizor.com's REST API. Includes Rails helpers.

Notifications You must be signed in to change notification settings

oktavilla/Resizor-gem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Resizor

For use with resizor.com

Inspired by Thoughtbot’s Paperclip

Usage

Add resizor to your Gemfile

gem 'resizor'

Install resizor gem

$ bundle install

Add a initializer to RAILS_ROOT/config/initializers/resizor.rb

Resizor.configure do |config|
  config.api_key = 'my-api-key' # find this on the Account screen when logged in on Resizor.com
  config.cdn_host = 'abc.cloudfront.net' # if you are using CloudFront to cache images generated by Resizor
end

Add Resizor fields to your model

$ rails generate resizor MyModel image

Add has_resizor_asset to MyModel

class MyModel < ActiveRecord::Base
  has_resizor_asset :image

  ...
end

Add a file field to the form for MyModel

<%= f.label :image %>
<%= f.file_field :image %>

Now you can resize your uploaded images on the fly

<% if my_model.image? %>
  <img src="<%= my_model.image.url(:size => 'c200x300') %>">
<% end %>

About

Let's you easily interface with Resizor.com's REST API. Includes Rails helpers.

Resources

Stars

Watchers

Forks

Packages

No packages published