Sha256: de06d37a8f273c82614c5bfa7b0cd2e07d465f2db26ef7d8be4c45c520b4dec8
Contents?: true
Size: 1022 Bytes
Versions: 9
Compression:
Stored size: 1022 Bytes
Contents
require_relative 'resource' require_relative 'resource/asset_fields' module Contentful # Resource class for Asset. # https://www.contentful.com/developers/documentation/content-delivery-api/#assets class Asset include Contentful::Resource include Contentful::Resource::SystemProperties include Contentful::Resource::AssetFields # Returns the image url of an asset # Allows you to pass in the following options for image resizing: # :width # :height # :format # :quality # See https://www.contentful.com/developers/documentation/content-delivery-api/#image-asset-resizing def image_url(options = {}) query = { w: options[:w] || options[:width], h: options[:h] || options[:height], fm: options[:fm] || options[:format], q: options[:q] || options[:quality] }.reject { |k, v| v.nil? } if query.empty? file.url else "#{file.url}?#{URI.encode_www_form(query)}" end end end end
Version data entries
9 entries across 9 versions & 1 rubygems