Skip to content
Browse files

Added support for custom thumbnail class

  • Loading branch information...
1 parent 7c598fb commit 498ce7f6db27982093652794de0b6a0052fae836 @aiwilliams aiwilliams committed Sep 30, 2008
Showing with 5 additions and 2 deletions.
  1. +5 −2 lib/paperclip/attachment.rb
View
7 lib/paperclip/attachment.rb
@@ -15,7 +15,7 @@ def self.default_options
}
end
- attr_reader :name, :instance, :styles, :default_style, :convert_options
+ attr_reader :name, :instance, :styles, :default_style, :convert_options, :thumbnail_class
# Creates an Attachment object. +name+ is the name of the attachment, +instance+ is the
# ActiveRecord object instance it's attached to, and +options+ is the same as the hash
@@ -35,6 +35,8 @@ def initialize name, instance, options = {}
@storage = options[:storage]
@whiny_thumbnails = options[:whiny_thumbnails]
@convert_options = options[:convert_options] || {}
+ @thumbnail_class = options[:thumbnail_class] || Thumbnail
+
@options = options
@queued_for_delete = []
@queued_for_write = {}
@@ -253,7 +255,8 @@ def post_process #:nodoc:
begin
dimensions, format = args
dimensions = dimensions.call(instance) if dimensions.respond_to? :call
- @queued_for_write[name] = Thumbnail.make(@queued_for_write[:original],
+ thumbnail_class = @thumbnail_class.respond_to?(:call) ? @thumbnail_class.call(instance) : @thumbnail_class
+ @queued_for_write[name] = thumbnail_class.make(@queued_for_write[:original],
dimensions,
format,
extra_options_for(name),

0 comments on commit 498ce7f

Please sign in to comment.
Something went wrong with that request. Please try again.