Created
May 12, 2012 11:00
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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