Sha256: 1d2b9d4d5a3689304914cb3567fd44b11538967d739dbb2a5ee381116b84ff76
Contents?: true
Size: 1.92 KB
Versions: 4
Compression:
Stored size: 1.92 KB
Contents
module RailsAdminJcrop module AssetEngine class <<self def thumbnail_names(obj, field) obj.send(field).styles.keys end def crop!(obj, field) obj.send(field).reprocess! end end end end module Paperclip module NewClassMethods def has_attached_file(*args) super self.attachment_definitions.each do |name, options| options[:processors] ||= [] options[:processors] << :rails_admin_jcropper end end end module ClassMethods def self.extended(base) super base.send :extend, ::Paperclip::NewClassMethods end end class RailsAdminJcropper < Thumbnail def transformation_command if @attachment.instance.rails_admin_cropping? ary = super if i = ary.index('-crop') ary.delete_at i ary.delete_at i+1 end ['-crop', crop_params] + ary else super end end def crop_params target = @attachment.instance "'#{target.crop_w.to_i}x#{target.crop_h.to_i}+#{target.crop_x.to_i}+#{target.crop_y.to_i}'" end end end module RailsAdmin module Config module Fields module Types module UploaderMethods def self.included(base) base.register_instance_option(:cache_method) do nil end base.register_instance_option(:thumb_method) do @thumb_method ||= ((styles = bindings[:object].send(name).styles.keys).find{|k| k.in?([:thumb, :thumbnail, 'thumb', 'thumbnail'])} || styles.first.to_s) end base.register_instance_option(:delete_method) do nil end end def resource_url(thumb = false) return nil unless (attachment = bindings[:object].send(name)).present? thumb.present? ? attachment.url(thumb) : attachment.url end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems