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
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)
-
- (String) image_url(options = {})
Generates a URL for the Contentful Image API.
Methods included from Resource::AssetFields
Methods included from Resource
#array?, #fields, #localized?, #reload, #sys
Instance Method Details
- (String) image_url(options = {})
Generates a URL for the Contentful Image API
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/contentful/asset.rb', line 22 def image_url( = {}) query = { w: [:w] || [:width], h: [:h] || [:height], fm: [:fm] || [:format], q: [:q] || [:quality], f: [:f] || [:focus], fit: [:fit] }.reject { |_k, v| v.nil? } if query.empty? file.url else "#{file.url}?#{URI.encode_www_form(query)}" end end |