Commit 5f2b2cd5 by jyurek

Added per-attachment whiny_thumbnail settings.

git-svn-id: https://svn.thoughtbot.com/plugins/paperclip/trunk@302 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
parent 53f9558a
......@@ -44,6 +44,7 @@ module Paperclip
end
def []=(style, data) #:nodoc:
@dirty = true
@files[style] = data
end
......@@ -150,10 +151,10 @@ module Paperclip
# Generates the thumbnails from the data supplied. Following this call, the data will
# be available from for_attached_files.
def convert data
def convert(uploaded_file)
begin
definition.styles.each do |style, geometry|
self[style] = Thumbnail.make(geometry, data)
self[style] = Thumbnail.make(geometry, data, definition.whiny_thumbnails)
end
rescue PaperclipError => e
errors << e.message
......
......@@ -49,12 +49,14 @@ module Paperclip
attr_accessor :geometry, :data
def initialize geometry, data
def initialize geometry, data, whiny_thumbnails = nil
@geometry, @data = geometry, data
@whiny_thumbnails = Paperclip.options[:whiny_thumbnails]
@whiny_thumbnails = whiny_thumbnails unless whiny_thumbnails.nil?
end
def self.make geometry, data
new(geometry, data).make
def self.make geometry, data, whiny_thumbnails = nil
new(geometry, data, whiny_thumbnails).make
end
def make
......@@ -70,8 +72,10 @@ module Paperclip
raise PaperclipError, "could not be thumbnailed. Is ImageMagick or GraphicsMagick installed and available?"
rescue SystemCallError => e
raise PaperclipError, "could not be thumbnailed."
rescue PaperclipError
raise if @whiny_thumbnails
end
if Paperclip.options[:whiny_thumbnails] && !$?.success?
if @whiny_thumbnails && !$?.success?
raise PaperclipError, "could not be thumbnailed because of an error with 'convert'."
end
thumb
......
......@@ -9,7 +9,7 @@ module Paperclip
type = self.path.match(/\.(\w+)$/)[1] || "data"
case type
when "jpg", "png", "gif" then "image/#{type}"
when "txt", "csv", "xml", "html", "htm" then "text/#{type}"
when "txt", "csv", "xml", "html", "htm", "css", "js" then "text/#{type}"
else "x-application/#{type}"
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment