Module: Alchemy::Picture::Url
Constant Summary collapse
- TRANSFORMATION_OPTIONS =
[ :crop, :crop_from, :crop_size, :flatten, :format, :quality, :size, :upsample ]
Instance Method Summary collapse
-
#url(options = {}) ⇒ Object
Returns a path to picture for use inside a image_tag helper.
Methods included from Logger
Instance Method Details
#url(options = {}) ⇒ Object
Returns a path to picture for use inside a image_tag helper.
Any additional options are passed to the url_helper, so you can add arguments to your url.
Example:
<%= image_tag picture.url(size: '320x200', format: 'png') %>
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/models/alchemy/picture/url.rb', line 26 def url( = {}) image = image_file raise MissingImageFileError, "Missing image file for #{inspect}" if image.nil? image = processed_image(image, ) image = encoded_image(image, ) image.url(.except(*TRANSFORMATION_OPTIONS).merge(name: name)) rescue MissingImageFileError, WrongImageFormatError => e log_warning e. nil end |