Created
September 5, 2011 19:46
-
-
Save cmaujean/1195759 to your computer and use it in GitHub Desktop.
S3 for uploaded images, and automatic watermarking in Spree 0-60-stable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/models/image_decorator.rb | |
Image.class_eval do | |
has_attached_file( | |
:attachment, | |
:storage => :s3, | |
:bucket => ENV['S3_BUCKET'] | |
:s3_credentials => { | |
:access_key_id => ENV['S3_KEY'], | |
:secret_access_key => ENV['S3_SECRET'] | |
}, | |
:processors => [:thumbnail, :watermark], | |
:styles => { | |
:mini => { | |
:geometry => '48x48>', | |
:watermark_path => "#{Rails.root.to_s}/public/images/watermarks/tiny.png", | |
:watermark_position => "SouthWest", | |
:format => :png, | |
}, | |
:small => { | |
:geometry => '100x100>', | |
:watermark_path => "#{Rails.root.to_s}/public/images/watermarks/small.png", | |
:watermark_position => "SouthWest", | |
:format => :png, | |
}, | |
:product => { | |
:geometry => '240x240>', | |
:watermark_path => "#{Rails.root.to_s}/public/images/watermarks/product.png", | |
:watermark_position => "SouthWest", | |
:format => :png, | |
}, | |
:large => { | |
:geometry => '600x600>', | |
:watermark_path => "#{Rails.root.to_s}/public/images/watermarks/large.png", | |
:watermark_position => "SouthWest", | |
:format => :png, | |
}, | |
}, | |
:default_style => :product, | |
:url => "/assets/products/:id/:style/:basename.:extension", | |
:path => ":rails_root/public/assets/products/:id/:style/:basename.:extension" | |
) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment