-
-
Save andreiglingeanu/920aa9227ab6f33d3dc2 to your computer and use it in GitHub Desktop.
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 ApplicationHelper | |
# a helper to get a data uri for an image asset | |
# e.g. <img src="<%= asset_data_uri('facebook.png') %>" /> | |
def asset_data_uri(path) | |
asset = asset_paths.asset_for path, nil | |
base64 = Base64.encode64(asset.to_s).gsub(/\s+/, "") | |
"data:#{asset.content_type};base64,#{Rack::Utils.escape(base64)}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment