Class: Integral::Image

Inherits:
ApplicationRecord show all
Defined in:
app/models/integral/image.rb

Overview

Represents an image uploaded by a user

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.listable_optionsHash

Returns listable options to be used within a RecordSelector widget.

Returns:

  • (Hash)

    listable options to be used within a RecordSelector widget



45
46
47
48
49
50
51
# File 'app/models/integral/image.rb', line 45

def self.listable_options
  {
    record_title: I18n.t('integral.backend.record_selector.images.record'),
    selector_path: Engine.routes.url_helpers.backend_images_path,
    selector_title: I18n.t('integral.backend.record_selector.images.title')
  }
end

Instance Method Details

#dimensionsString

Returns represents the dimensions of the original image.

Returns:

  • (String)

    represents the dimensions of the original image



29
30
31
# File 'app/models/integral/image.rb', line 29

def dimensions
  "#{width}x#{height}px" if width && height
end

#to_list_itemHash

Returns the instance as a list item.

Returns:

  • (Hash)

    the instance as a list item



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

def to_list_item
  {
    id: id,
    title: title,
    subtitle: description,
    description: description,
    image: file
  }
end