Class: Refinery::Image

Inherits:
Core::BaseModel show all
Extended by:
Mobility
Includes:
Refinery::Images::Validators
Defined in:
images/app/models/refinery/image.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Core::BaseModel

#users_manager

Class Method Details

.per_page(dialog = false, has_size_options = false) ⇒ Object

How many images per page should be displayed?


34
35
36
37
38
39
40
41
42
43
44
# File 'images/app/models/refinery/image.rb', line 34

def per_page(dialog = false, has_size_options = false)
  if dialog
    if has_size_options
      Images.pages_per_dialog_that_have_size_options
    else
      Images.pages_per_dialog
    end
  else
    Images.pages_per_admin_index
  end
end

Instance Method Details

#altObject


70
71
72
# File 'images/app/models/refinery/image.rb', line 70

def alt
  image_alt.presence || title
end

#thumbnail(options = {}) ⇒ Object

Get a thumbnail job object given a geometry and whether to strip image profiles and comments.


48
49
50
51
52
53
54
55
# File 'images/app/models/refinery/image.rb', line 48

def thumbnail(options = {})
  options = { geometry: nil, strip: false }.merge(options)
  geometry = convert_to_geometry(options[:geometry])
  thumbnail = image
  thumbnail = thumbnail.thumb(geometry) if geometry
  thumbnail = thumbnail.strip if options[:strip]
  thumbnail
end

#thumbnail_dimensions(geometry) ⇒ Object

Intelligently works out dimensions for a thumbnail of this image based on the Dragonfly geometry string.


58
59
60
61
# File 'images/app/models/refinery/image.rb', line 58

def thumbnail_dimensions(geometry)
  dimensions = ThumbnailDimensions.new(geometry, image.width, image.height)
  { width: dimensions.width, height: dimensions.height }
end

#titleObject

Returns a titleized version of the filename my_file.jpg returns My File


66
67
68
# File 'images/app/models/refinery/image.rb', line 66

def title
  image_title.presence || CGI::unescape(image_name.to_s).gsub(/\.\w+$/, '').titleize
end