Class: Refinery::Image

Inherits:
Core::BaseModel show all
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?



26
27
28
29
30
31
32
33
34
35
36
# File 'images/app/models/refinery/image.rb', line 26

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



62
63
64
# File 'images/app/models/refinery/image.rb', line 62

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.



40
41
42
43
44
45
46
47
# File 'images/app/models/refinery/image.rb', line 40

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.



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

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



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

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