Class: Contentful::Asset
- Inherits:
-
Object
- Object
- Contentful::Asset
- Includes:
- Resource, Resource::AssetFields, Resource::SystemProperties
- Defined in:
- lib/contentful/asset.rb
Overview
Resource class for Asset. www.contentful.com/developers/documentation/content-delivery-api/#assets
Constant Summary
Constants included from Resource::AssetFields
Resource::AssetFields::FIELDS_COERCIONS
Instance Attribute Summary
Attributes included from Resource::SystemProperties
Attributes included from Resource
#client, #default_locale, #properties, #raw, #request
Instance Method Summary collapse
-
#image_url(options = {}) ⇒ String
(also: #url)
Generates a URL for the Contentful Image API.
Methods included from Resource::AssetFields
Methods included from Resource
#array?, #entry?, #fields, #reload, #sys
Instance Method Details
#image_url(options = {}) ⇒ String Also known as: url
Generates a URL for the Contentful Image API
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/contentful/asset.rb', line 38 def image_url( = {}) query = { w: [:w] || [:width], h: [:h] || [:height], fm: [:fm] || [:format], q: [:q] || [:quality], f: [:f] || [:focus], fit: [:fit], fl: [:fl] }.reject { |_k, v| v.nil? } if query.empty? file.url else "#{file.url}?#{URI.encode_www_form(query)}" end end |