class Dato::Local::FieldType::UploadId
Attributes
format[R]
height[R]
path[R]
size[R]
width[R]
Public Class Methods
new( path, format, size, width, height, imgix_host )
click to toggle source
# File lib/dato/local/field_type/upload_id.rb, line 28 def initialize( path, format, size, width, height, imgix_host ) @path = path @format = format @size = size @imgix_host = imgix_host @width = width @height = height end
parse(upload_id, repo)
click to toggle source
# File lib/dato/local/field_type/upload_id.rb, line 11 def self.parse(upload_id, repo) if upload_id upload = repo.entities_repo.find_entity("upload", upload_id) if upload new( upload.path, upload.format, upload.size, upload.width, upload.height, repo.site.entity.imgix_host, ) end end end
Public Instance Methods
file()
click to toggle source
# File lib/dato/local/field_type/upload_id.rb, line 44 def file Imgix::Client.new( domain: @imgix_host, secure: true, include_library_param: false, ).path(path) end
to_hash(*_args)
click to toggle source
# File lib/dato/local/field_type/upload_id.rb, line 56 def to_hash(*_args) { format: format, size: size, width: width, height: height, url: url, } end
url(opts = {})
click to toggle source
# File lib/dato/local/field_type/upload_id.rb, line 52 def url(opts = {}) file.to_url(opts) end