Skip to content

Instantly share code, notes, and snippets.

@mschuerig
Created June 8, 2012 06:57
Show Gist options
  • Save mschuerig/2894073 to your computer and use it in GitHub Desktop.
Save mschuerig/2894073 to your computer and use it in GitHub Desktop.
CSS helper that inserts small files as data URIs
# Monkey-patch another helper into Sprockets that expands small files
# into data URIs.
module Sprockets
class Context
def asset_uri(path)
fullpath = environment.find_asset(path)
if fullpath && File.file?(fullpath) && File.size(fullpath) < 2048
asset_data_uri(path)
else
path
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment