Class: Pageflow::ImageFile
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Pageflow::ImageFile
- Defined in:
- app/models/pageflow/image_file.rb
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(*args) ⇒ 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
69 70 71 72 73 74 75 76 77 78 |
# File 'app/models/pageflow/image_file.rb', line 69 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 ->
33 34 35 |
# File 'app/models/pageflow/image_file.rb', line 33 def ':pageflow_placeholder' end |
#attachment_styles(attachment) ⇒ Object
37 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 |
# File 'app/models/pageflow/image_file.rb', line 37 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'} ) 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
24 25 26 |
# File 'app/models/pageflow/image_file.rb', line 24 def original_url .url if ready? end |
#panorama_url ⇒ Object
28 29 30 |
# File 'app/models/pageflow/image_file.rb', line 28 def panorama_url .url(:panorama_large) if ready? end |
#thumbnail_url(*args) ⇒ Object
17 18 19 20 21 22 |
# File 'app/models/pageflow/image_file.rb', line 17 def thumbnail_url(*args) unless ready? return Pageflow::PaperclipInterpolations::Support.pageflow_placeholder(, *args) end .url(*args) end |
#url ⇒ Object
64 65 66 |
# File 'app/models/pageflow/image_file.rb', line 64 def url .url(:large) if ready? end |