Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use uploader class for carrierwave #143

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/rich.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def self.image_styles=(image_styles)
mattr_accessor :backend
@@backend = :paperclip

mattr_accessor :uploader
@@uploader = "RichFileUploader"

# configuration for picker
mattr_accessor :placeholder_image
@@placeholder_image = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" # a transparent pixel
Expand Down
16 changes: 15 additions & 1 deletion lib/rich/backends/carrierwave.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,21 @@ module Backends
module CarrierWave
extend ActiveSupport::Concern

module DefaultCarrierwaveVersions
Rich.image_styles.each do |name,size|
unless Rich.uploader.constantize.versions.include? name
Rich.uploader.constantize.send :version, name.to_s do
process :resize_to_fit => size.gsub("#", "").split("x").map(&:to_i)
end
end
end
end

included do
mount_uploader :rich_file_file_name, RichFileUploader
uploader = Rich.uploader.constantize
uploader.include(DefaultCarrierwaveVersions)

mount_uploader :rich_file_file_name, uploader
alias_method :rich_file, :rich_file_file_name
alias_method :rich_file=, :rich_file_file_name=

Expand Down Expand Up @@ -66,6 +79,7 @@ def clear_uri_cache
module ClassMethods

end

end
end

Expand Down
5 changes: 0 additions & 5 deletions lib/rich/backends/rich_file_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ def store_dir
# # do something
# end

Rich.image_styles.each do |name,size|
version name do
process :resize_to_fit => size.gsub("#", "").split("x").map(&:to_i)
end
end
# version :rich_thumb do
# process :resize_to_fit => [100, 100]
# end
Expand Down