Class: Pageflow::ImageFile

Inherits:
ApplicationRecord show all
Includes:
ImageAndTextTrackProcessingStateMachine, UploadableFile
Defined in:
app/models/pageflow/image_file.rb

Instance Method Summary collapse

Methods included from ImageAndTextTrackProcessingStateMachine

#failed?, #ready?, #retry!, #retryable?

Methods included from UploadableFile

#attachment, #attachment=, #attachments_for_export, #basename, #can_upload?, #direct_upload_config, #failed?, #publish!, #ready?, #retryable?

Methods included from ReusableFile

#attachments_for_export, #basename, #cache_key, #can_upload?, #failed?, #file_name, #file_type, #nested_files, #parent_allows_type_for_nesting, #parent_belongs_to_same_entry, #publish!, #ready?, #retry!, #retryable?

Instance Method Details

#attachment_default_urlObject

UploadableFile-overrides ->



30
31
32
# File 'app/models/pageflow/image_file.rb', line 30

def attachment_default_url
  ':pageflow_placeholder'
end

#attachment_styles(attachment) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/models/pageflow/image_file.rb', line 34

def attachment_styles(attachment)
  panorama_format = File.extname(attachment.original_filename) == '.png' ? :PNG : :JPG

  Pageflow
    .config.thumbnail_styles
    .merge(
      print: {geometry: '300x300>',
              format: :JPG,
              convert_options: '-quality 10 -interlace Plane'},
      medium: {geometry: '1024x1024>',
               format: :JPG,
               convert_options: '-quality 70 -interlace Plane'},
      large: {geometry: '1920x1920>',
              format: :JPG,
              convert_options: '-quality 70 -interlace Plane'},
      ultra: {geometry: '3840x3840>',
              format: :JPG,
              convert_options: '-quality 90 -interlace Plane'},
      panorama_medium: {geometry: '1024x1024^',
                        format: panorama_format,
                        convert_options: '-quality 90 -interlace Plane'},
      panorama_large: {geometry: '1920x1080^',
                       format: panorama_format,
                       convert_options: '-quality 90 -interlace Plane'}
    )
end

#attachments_path_nameObject

used in paperclip initializer to interpolate the storage path needs to be “processed_attachments” for images for legacy reasons



8
9
10
# File 'app/models/pageflow/image_file.rb', line 8

def attachments_path_name
  'processed_attachments'
end

#original_urlObject



21
22
23
# File 'app/models/pageflow/image_file.rb', line 21

def original_url
  attachment.url if ready?
end

#panorama_urlObject



25
26
27
# File 'app/models/pageflow/image_file.rb', line 25

def panorama_url
  attachment.url(:panorama_large) if ready?
end

#thumbnail_url(*args) ⇒ Object



14
15
16
17
18
19
# File 'app/models/pageflow/image_file.rb', line 14

def thumbnail_url(*args)
  unless ready?
    return Pageflow::PaperclipInterpolations::Support.pageflow_placeholder(attachment, *args)
  end
  attachment.url(*args)
end

#urlObject



61
62
63
# File 'app/models/pageflow/image_file.rb', line 61

def url
  attachment.url(:large) if ready?
end