Class: Decidim::ImageUploader
- Inherits:
-
ApplicationUploader
- Object
- ApplicationUploader
- Decidim::ImageUploader
- Defined in:
- app/uploaders/decidim/image_uploader.rb
Overview
This class deals with uploading hero images to ParticipatoryProcesses.
Direct Known Subclasses
AvatarUploader, EditorImageUploader, NewsletterTemplateImageUploader, OrganizationFaviconUploader, RecordImageUploader
Instance Attribute Summary
Attributes inherited from ApplicationUploader
#content_type_denylist, #model, #mounted_as
Instance Method Summary collapse
- #content_type_allowlist ⇒ Object
-
#dimensions_info ⇒ Object
Fetches info about different variants, their processors and dimensions.
-
#extension_allowlist ⇒ Object
Add a white list of extensions which are allowed to be uploaded.
- #max_image_height_or_width ⇒ Object
- #validable_dimensions ⇒ Object
Methods inherited from ApplicationUploader
#attached?, #initialize, #path, #remote_url=, set_variants, #store_dir, #url, #variant, #variant_path, #variant_url, variants
Constructor Details
This class inherits a constructor from Decidim::ApplicationUploader
Instance Method Details
#content_type_allowlist ⇒ Object
10 11 12 |
# File 'app/uploaders/decidim/image_uploader.rb', line 10 def content_type_allowlist extension_allowlist.map { |ext| MiniMime.lookup_by_extension(ext).content_type }.uniq end |
#dimensions_info ⇒ Object
Fetches info about different variants, their processors and dimensions
15 16 17 18 19 20 21 22 23 24 |
# File 'app/uploaders/decidim/image_uploader.rb', line 15 def dimensions_info return if variants.blank? variants.transform_values do |variant| { processor: variant.keys.first, dimensions: variant.values.first } end end |
#extension_allowlist ⇒ Object
Add a white list of extensions which are allowed to be uploaded. For images you might use something like this:
28 29 30 |
# File 'app/uploaders/decidim/image_uploader.rb', line 28 def extension_allowlist Decidim.organization_settings(model).upload_allowed_file_extensions_image end |
#max_image_height_or_width ⇒ Object
32 33 34 |
# File 'app/uploaders/decidim/image_uploader.rb', line 32 def max_image_height_or_width 3840 end |
#validable_dimensions ⇒ Object
6 7 8 |
# File 'app/uploaders/decidim/image_uploader.rb', line 6 def validable_dimensions true end |