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
Constants included from Resource::SystemProperties
Resource::SystemProperties::SYS_COERCIONS
Constants included from Resource
Instance Attribute Summary
Attributes included from Resource::SystemProperties
Attributes included from Resource
#client, #default_locale, #properties, #request
Instance Method Summary collapse
-
#image_url(options = {}) ⇒ Object
Returns the image url of an asset Allows you to pass in the following options for image resizing: :width :height :format :quality See www.contentful.com/developers/documentation/content-delivery-api/#image-asset-resizing.
Methods included from Resource::AssetFields
#fields, included, #initialize, #inspect
Methods included from Resource::SystemProperties
included, #initialize, #inspect
Methods included from Resource
#array?, #fields, #initialize, #inspect, #nested_locale_fields?, #reload, #sys
Instance Method Details
#image_url(options = {}) ⇒ Object
Returns the image url of an asset Allows you to pass in the following options for image resizing:
:width
:height
:format
:quality
See www.contentful.com/developers/documentation/content-delivery-api/#image-asset-resizing
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/contentful/asset.rb', line 19 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 |