Class: Refinery::Image
- Inherits:
-
Core::BaseModel
- Object
- ActiveRecord::Base
- Core::BaseModel
- Refinery::Image
- Extended by:
- Mobility
- Includes:
- Refinery::Images::Validators
- Defined in:
- images/app/models/refinery/image.rb
Class Method Summary collapse
-
.per_page(dialog = false, has_size_options = false) ⇒ Object
How many images per page should be displayed?.
Instance Method Summary collapse
- #alt ⇒ Object
-
#thumbnail(options = {}) ⇒ Object
Get a thumbnail job object given a geometry and whether to strip image profiles and comments.
-
#thumbnail_dimensions(geometry) ⇒ Object
Intelligently works out dimensions for a thumbnail of this image based on the Dragonfly geometry string.
-
#title ⇒ Object
Returns a titleized version of the filename my_file.jpg returns My File.
Methods inherited from Core::BaseModel
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, = false) if dialog if Images. else Images.pages_per_dialog end else Images.pages_per_admin_index end end |
Instance Method Details
#alt ⇒ Object
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( = {}) = { geometry: nil, strip: false }.merge() geometry = convert_to_geometry([:geometry]) thumbnail = image thumbnail = thumbnail.thumb(geometry) if geometry thumbnail = thumbnail.strip if [: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 |
#title ⇒ Object
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 |