Sha256: c0d5b381c1689761ed2c112c5fb855e409ea2568368b0a683869eafdf6810f5d

Contents?: true

Size: 1.3 KB

Versions: 27

Compression:

Stored size: 1.3 KB

Contents

module DynamicScaffold
  module Form
    module Item
      class CarrierWaveImage < Base
        attr_reader :options
        def initialize(config, type, name, options = {})
          super(config, type, name, {})
          @options = options
          @options[:removable] = true if @options[:removable].nil?
        end

        def cropper
          return nil unless @options.key? :cropper
          return {} if @options[:cropper] == true

          @options[:cropper]
        end

        def preview_image_style
          max_size = @options[:preview_max_size]
          return '' unless max_size

          ' '.tap do |s|
            s << "max-width: #{max_size[:width]};" if max_size[:width]
            s << "max-height: #{max_size[:height]};" if max_size[:height]
          end
        end

        def render(_view, _form, classnames = nil)
          html_attributes = build_html_attributes(classnames)
          yield(html_attributes)
        end

        def extract_parameters(permitting)
          # If you do not permit before the image body you can not use cropper value in uploader.
          permitting << "cropper_#{@name}" unless cropper.nil?
          permitting << "remove_#{@name}" if @options[:removable]
          permitting.concat(["#{@name}_cache", @name])
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
dynamic_scaffold-1.12.2 lib/dynamic_scaffold/form/item/carrier_wave_image.rb
dynamic_scaffold-1.12.1 lib/dynamic_scaffold/form/item/carrier_wave_image.rb
dynamic_scaffold-1.12.0 lib/dynamic_scaffold/form/item/carrier_wave_image.rb
dynamic_scaffold-1.11.0 lib/dynamic_scaffold/form/item/carrier_wave_image.rb
dynamic_scaffold-1.10.0 lib/dynamic_scaffold/form/item/carrier_wave_image.rb
dynamic_scaffold-1.9.0 lib/dynamic_scaffold/form/item/carrier_wave_image.rb
dynamic_scaffold-1.8.1 lib/dynamic_scaffold/form/item/carrier_wave_image.rb
dynamic_scaffold-1.8.0 lib/dynamic_scaffold/form/item/carrier_wave_image.rb
dynamic_scaffold-1.7.1 lib/dynamic_scaffold/form/item/carrier_wave_image.rb
dynamic_scaffold-1.7.0 lib/dynamic_scaffold/form/item/carrier_wave_image.rb
dynamic_scaffold-1.6.0 lib/dynamic_scaffold/form/item/carrier_wave_image.rb
dynamic_scaffold-1.5.0 lib/dynamic_scaffold/form/item/carrier_wave_image.rb
dynamic_scaffold-1.4.3 lib/dynamic_scaffold/form/item/carrier_wave_image.rb
dynamic_scaffold-1.4.2 lib/dynamic_scaffold/form/item/carrier_wave_image.rb
dynamic_scaffold-1.4.1 lib/dynamic_scaffold/form/item/carrier_wave_image.rb
dynamic_scaffold-1.4.0 lib/dynamic_scaffold/form/item/carrier_wave_image.rb
dynamic_scaffold-1.3.0 lib/dynamic_scaffold/form/item/carrier_wave_image.rb
dynamic_scaffold-1.2.2 lib/dynamic_scaffold/form/item/carrier_wave_image.rb
dynamic_scaffold-1.2.1 lib/dynamic_scaffold/form/item/carrier_wave_image.rb
dynamic_scaffold-1.2.0 lib/dynamic_scaffold/form/item/carrier_wave_image.rb