Class: Pageflow::ImageFile
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Pageflow::ImageFile
- Defined in:
- app/models/pageflow/image_file.rb
Overview
rubocop:todo Style/Documentation
Constant Summary
Constants included from OutputSource
Class Method Summary collapse
-
.scale_down_to_cover(width, height) ⇒ Object
<- UploadableFile-overrides.
Instance Method Summary collapse
-
#attachment_default_url ⇒ Object
UploadableFile-overrides ->.
- #attachment_styles(attachment) ⇒ Object
-
#attachments_path_name ⇒ Object
used in paperclip initializer to interpolate the storage path needs to be "processed_attachments" for images for legacy reasons.
- #original_url ⇒ Object
- #panorama_url ⇒ Object
- #thumbnail_url ⇒ Object
- #url ⇒ Object
Methods included from OutputSource
#externally_generated_outputs, #output_presences, #output_presences=, #output_present?, #present_outputs
Methods included from ImageAndTextTrackProcessingStateMachine
#failed?, #ready?, #retry!, #retryable?
Methods included from UploadableFile
#attachment, #attachment=, #attachments_for_export, #basename, #can_upload?, #direct_upload_config, #extension, #failed?, #file_name, #publish!, #ready?, #retryable?
Methods included from ReusableFile
#attachments_for_export, #basename, #cache_key, #can_upload?, #extension, #failed?, #file_name, #file_type, #nested_files, #parent_allows_type_for_nesting, #parent_belongs_to_same_entry, #publish!, #ready?, #retry!, #retryable?
Class Method Details
.scale_down_to_cover(width, height) ⇒ Object
<- UploadableFile-overrides
75 76 77 78 79 80 81 82 83 84 |
# File 'app/models/pageflow/image_file.rb', line 75 def self.scale_down_to_cover(width, height) lambda do |image_file| if image_file.width.present? && image_file.height.present? && (image_file.width <= width || image_file.height <= height) '100%' else "#{width}x#{height}^" end end end |
Instance Method Details
#attachment_default_url ⇒ Object
UploadableFile-overrides ->
34 35 36 |
# File 'app/models/pageflow/image_file.rb', line 34 def ':pageflow_placeholder' end |
#attachment_styles(attachment) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/models/pageflow/image_file.rb', line 38 def () panorama_format = File.extname(.original_filename) == '.png' ? :PNG : :JPG Pageflow .config.thumbnail_styles.transform_values { || .merge(style_defaults) } .merge( print: {geometry: '300x300>', **style_defaults, convert_options: '-quality 10 -interlace Plane'}, medium: {geometry: '1024x1024>', **style_defaults, convert_options: '-quality 70 -interlace Plane'}, large: {geometry: '1920x1920>', **style_defaults, convert_options: '-quality 70 -interlace Plane'}, ultra: {geometry: '3840x3840>', **style_defaults, convert_options: '-quality 90 -interlace Plane'}, panorama_medium: { geometry: ImageFile.scale_down_to_cover(1024, 1024), format: panorama_format, convert_options: '-quality 90 -interlace Plane' }, panorama_large: { geometry: ImageFile.scale_down_to_cover(1920, 1080), format: panorama_format, convert_options: '-quality 90 -interlace Plane' } ) .merge() end |
#attachments_path_name ⇒ Object
used in paperclip initializer to interpolate the storage path needs to be "processed_attachments" for images for legacy reasons
11 12 13 |
# File 'app/models/pageflow/image_file.rb', line 11 def 'processed_attachments' end |
#original_url ⇒ Object
25 26 27 |
# File 'app/models/pageflow/image_file.rb', line 25 def original_url .url if ready? end |
#panorama_url ⇒ Object
29 30 31 |
# File 'app/models/pageflow/image_file.rb', line 29 def panorama_url .url(:panorama_large) if ready? end |
#thumbnail_url ⇒ Object
17 18 19 20 21 22 23 |
# File 'app/models/pageflow/image_file.rb', line 17 def thumbnail_url(*) unless ready? return Pageflow::PaperclipInterpolations::Support.pageflow_placeholder(, *) end .url(*) end |
#url ⇒ Object
70 71 72 |
# File 'app/models/pageflow/image_file.rb', line 70 def url .url(:large) if ready? end |