class Agave::Local::FieldType::Image
Attributes
alt[R]
format[R]
height[R]
image_host[R]
path[R]
size[R]
title[R]
width[R]
Public Class Methods
new( path, format, size, width, height, alt, title, image_host )
click to toggle source
# 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
parse(upload_attributes, repo)
click to toggle source
# 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
Public Instance Methods
file()
click to toggle source
# 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)
click to toggle source
# 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 = {})
click to toggle source
# File lib/agave/local/field_type/image.rb, line 64 def url(opts = {}) file.to_url(opts) end