Class: Agave::Local::FieldType::Image
- Inherits:
-
Object
- Object
- Agave::Local::FieldType::Image
- Defined in:
- lib/agave/local/field_type/image.rb
Instance Attribute Summary collapse
-
#alt ⇒ Object
readonly
Returns the value of attribute alt.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#image_host ⇒ Object
readonly
Returns the value of attribute image_host.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Class Method Summary collapse
Instance Method Summary collapse
- #file ⇒ Object
-
#initialize(path, format, size, width, height, alt, title, image_host) ⇒ Image
constructor
A new instance of Image.
- #to_hash(*_args) ⇒ Object
- #url(opts = {}) ⇒ Object
Constructor Details
#initialize(path, format, size, width, height, alt, title, image_host) ⇒ Image
Returns a new instance of Image.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/agave/local/field_type/image.rb', line 36 def initialize( path, format, size, width, height, alt, title, image_host ) @path = path @format = format @size = size @width = width @height = height @title = title @alt = alt @image_host = image_host end |
Instance Attribute Details
#alt ⇒ Object (readonly)
Returns the value of attribute alt.
14 15 16 |
# File 'lib/agave/local/field_type/image.rb', line 14 def alt @alt end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
9 10 11 |
# File 'lib/agave/local/field_type/image.rb', line 9 def format @format end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
12 13 14 |
# File 'lib/agave/local/field_type/image.rb', line 12 def height @height end |
#image_host ⇒ Object (readonly)
Returns the value of attribute image_host.
15 16 17 |
# File 'lib/agave/local/field_type/image.rb', line 15 def image_host @image_host end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/agave/local/field_type/image.rb', line 8 def path @path end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
10 11 12 |
# File 'lib/agave/local/field_type/image.rb', line 10 def size @size end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
13 14 15 |
# File 'lib/agave/local/field_type/image.rb', line 13 def title @title end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
11 12 13 |
# File 'lib/agave/local/field_type/image.rb', line 11 def width @width end |
Class Method Details
.parse(upload_attributes, repo) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/agave/local/field_type/image.rb', line 17 def self.parse(upload_attributes, repo) return nil if !upload_attributes return nil if !upload_attributes[:path] upload = repo.entities_repo.find_entity( "upload", upload_attributes[:path] ) return nil if !upload new( upload.path, upload.format, upload.size, upload.width, upload.height, upload.alt, upload.title, repo.site.entity.image_host ) end |
Instance Method Details
#file ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/agave/local/field_type/image.rb', line 56 def file Imgix::Client.new( host: image_host, secure: true, include_library_param: false ).path(path) end |
#to_hash(*_args) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/agave/local/field_type/image.rb', line 68 def to_hash(*_args) { format: format, size: size, width: width, height: height, alt: alt, title: title, url: url } end |
#url(opts = {}) ⇒ Object
64 65 66 |
# File 'lib/agave/local/field_type/image.rb', line 64 def url(opts = {}) file.to_url(opts) end |