Sha256: 1dd813ae62036e687309dcc99a8cf3d8bd2d712183f49e2f4e97c61390d9bd33
Contents?: true
Size: 1.36 KB
Versions: 3
Compression:
Stored size: 1.36 KB
Contents
# frozen_string_literal: true require "imgix" module Dato module Local module FieldType class UploadId attr_reader :path, :format, :size, :width, :height 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 def initialize( path, format, size, width, height, imgix_host ) @path = path @format = format @size = size @imgix_host = imgix_host @width = width @height = height end def file Imgix::Client.new( domain: @imgix_host, secure: true, include_library_param: false, ).path(path) end def url(opts = {}) file.to_url(opts) end def to_hash(*_args) { format: format, size: size, width: width, height: height, url: url, } end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dato-0.8.3 | lib/dato/local/field_type/upload_id.rb |
dato-0.8.2 | lib/dato/local/field_type/upload_id.rb |
dato-0.8.1 | lib/dato/local/field_type/upload_id.rb |