Sha256: 76e601281fd82de856ef9a1fa0ec9883d5b58d08134a167410c467a1db8f34ae
Contents?: true
Size: 1.35 KB
Versions: 1
Compression:
Stored size: 1.35 KB
Contents
module ActionView module Helpers module AssetTagHelper ## # Displays a version of an upload and sets stored width and height attributes # # === Parameters # # [model (Model)] model instance # [mounted_to (Sym)] attribute to which uploader is mounted # [version (Sym)] version of the upload # [options (Hash)] optional options hash # # === Examples # # retina_image_tag(@user, :avatar, :small, :default => { :width => 300, :height => 200 }) # retina_image_tag(@user, :avatar, :small, :default => [300, 200]) # def retina_image_tag(model, mounted_to, version, options={}) default = options.delete(:default) # Check if we can find the dimensions of the uploaded image. # If no image or dimensions available use default. if model.retina_dimensions.kind_of?(Hash) && model.retina_dimensions[mounted_to.to_sym] dimensions = model.retina_dimensions[mounted_to.to_sym][version.to_sym] else if default.kind_of?(Array) default = { :width => default[0], :height => default[1] } end dimensions = default || {} end options = dimensions.merge(options) image_tag(model.send(mounted_to).url(version), options) end end # AssetTagHelper end # Helpers end # ActionView
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
retina_rails-2.0.5 | lib/retina_rails/helpers.rb |