Sha256: 84d4cbf1f29bfc296cadb783c13242edd3801fc6db4ec8c87464f516b7dacf84

Contents?: true

Size: 1.04 KB

Versions: 44

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module Decidim
  # This class deals with uploading attachments to a participatory space.
  class AttachmentUploader < ApplicationUploader
    def validable_dimensions
      true
    end

    set_variants do
      {
        thumbnail: { resize_to_fit: [nil, 237] },
        big: { resize_to_limit: [nil, 1000] }
      }
    end

    def extension_allowlist
      case upload_context
      when :admin
        Decidim.organization_settings(model).upload_allowed_file_extensions_admin
      else
        Decidim.organization_settings(model).upload_allowed_file_extensions
      end
    end

    def content_type_allowlist
      case upload_context
      when :admin
        Decidim.organization_settings(model).upload_allowed_content_types_admin
      else
        Decidim.organization_settings(model).upload_allowed_content_types
      end
    end

    def max_image_height_or_width
      8000
    end

    protected

    def upload_context
      return :participant unless model.respond_to?(:context)

      model.context
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/uploaders/decidim/attachment_uploader.rb
decidim-core-0.28.4 app/uploaders/decidim/attachment_uploader.rb
decidim-core-0.27.9 app/uploaders/decidim/attachment_uploader.rb
decidim-core-0.29.0 app/uploaders/decidim/attachment_uploader.rb
decidim-core-0.28.3 app/uploaders/decidim/attachment_uploader.rb
decidim-core-0.27.8 app/uploaders/decidim/attachment_uploader.rb
decidim-core-0.29.0.rc4 app/uploaders/decidim/attachment_uploader.rb
decidim-core-0.29.0.rc3 app/uploaders/decidim/attachment_uploader.rb
decidim-core-0.29.0.rc2 app/uploaders/decidim/attachment_uploader.rb
decidim-core-0.29.0.rc1 app/uploaders/decidim/attachment_uploader.rb
decidim-core-0.28.2 app/uploaders/decidim/attachment_uploader.rb
decidim-core-0.27.7 app/uploaders/decidim/attachment_uploader.rb
decidim-core-0.28.1 app/uploaders/decidim/attachment_uploader.rb
decidim-core-0.27.6 app/uploaders/decidim/attachment_uploader.rb
decidim-core-0.26.10 app/uploaders/decidim/attachment_uploader.rb
decidim-core-0.26.9 app/uploaders/decidim/attachment_uploader.rb
decidim-core-0.28.0 app/uploaders/decidim/attachment_uploader.rb
decidim-core-0.27.5 app/uploaders/decidim/attachment_uploader.rb
decidim-core-0.28.0.rc5 app/uploaders/decidim/attachment_uploader.rb
decidim-core-0.28.0.rc4 app/uploaders/decidim/attachment_uploader.rb