Module: ActionView::Helpers::AssetTagHelper
- Defined in:
- lib/retina_rails/helpers.rb
Instance Method Summary collapse
-
#retina_image_tag(model, mounted_to, version, options = {}) ⇒ Object
Displays a version of an upload and sets stored width and height attributes.
Instance Method Details
#retina_image_tag(model, mounted_to, version, options = {}) ⇒ Object
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])
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/retina_rails/helpers.rb', line 20 def retina_image_tag(model, mounted_to, version, ={}) default = .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 = dimensions.merge() image_tag(model.send(mounted_to).url(version), ) end |