Class: Pageflow::ImageFile

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
ImageFileStateMachine, UploadedFile
Defined in:
app/models/pageflow/image_file.rb

Constant Summary collapse

STYLES =
lambda do |attachment|
  panorama_format = File.extname(attachment.original_filename) == '.png' ? :PNG : :JPG

  Pageflow.config.thumbnail_styles
    .merge(print: ['300x300>', :JPG],
           medium: ['1024x1024>', :JPG],
           large: ['1920x1920>', :JPG],
           panorama_medium: ['1024x1024^', panorama_format],
           panorama_large: ['1920x1080^', panorama_format])
end
CONVERT_OPTIONS =
{
  print: '-quality 10 -interlace Plane',
  medium: '-quality 70 -interlace Plane',
  large: '-quality 70 -interlace Plane',
  panorama_medium: '-quality 70 -interlace Plane',
  panorama_large: '-quality 70 -interlace Plane'
}

Instance Method Summary collapse

Methods included from UploadedFile

#usage_id

Methods included from ImageFileStateMachine

#publish!, #retry!, #retryable?

Instance Method Details

#attachmentObject



39
40
41
# File 'app/models/pageflow/image_file.rb', line 39

def attachment
  processed_attachment.present? ? processed_attachment : unprocessed_attachment
end

#attachment=(value) ⇒ Object



43
44
45
# File 'app/models/pageflow/image_file.rb', line 43

def attachment=(value)
  self.unprocessed_attachment = value
end

#original_urlObject



57
58
59
60
61
# File 'app/models/pageflow/image_file.rb', line 57

def original_url
  if processed_attachment.present?
    attachment.url
  end
end

#panorama_urlObject



63
64
65
66
67
# File 'app/models/pageflow/image_file.rb', line 63

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

#thumbnail_url(*args) ⇒ Object



47
48
49
# File 'app/models/pageflow/image_file.rb', line 47

def thumbnail_url(*args)
  processed_attachment.url(*args)
end

#urlObject



51
52
53
54
55
# File 'app/models/pageflow/image_file.rb', line 51

def url
  if processed_attachment.present?
    attachment.url(:large)
  end
end