Skip to content

Instantly share code, notes, and snippets.

@elia
Created May 12, 2012 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elia/2665831 to your computer and use it in GitHub Desktop.
Save elia/2665831 to your computer and use it in GitHub Desktop.
Use dimensions by @sstephenson to add automatic images size and improve browser rendering
module DimensionsHelper
# How this improves browser rendering?
# https://developers.google.com/speed/docs/best-practices/rendering#SpecifyImageDimensions
#
def image_tag source, options = {}
unless options[:size]
fs_path = asset_paths.asset_for(source, nil)
options[:width], options[:height] = Dimensions.dimensions(fs_path)
end
super
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment