Sha256: ac9a6b486b12868709f6a4e4daf285155499296ba60f9a5b0a4b6f54d20d3901
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 KB
Contents
# frozen_string_literal: true require 'imgix' module Dato module Local module FieldType class File attr_reader :path, :format, :size, :width, :height, :title, :alt 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, upload.alt, upload.title, repo.site.entity.imgix_host ) end end end def initialize( path, format, size, width, height, alt, title, imgix_host ) @path = path @format = format @size = size @imgix_host = imgix_host @width = width @height = height @alt = alt @title = title end def file Imgix::Client.new( host: @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, alt: alt, title: title, url: url } end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dato-0.6.9 | lib/dato/local/field_type/file.rb |
dato-0.6.8 | lib/dato/local/field_type/file.rb |