Skip to content

Instantly share code, notes, and snippets.

@CameronGilroy
Forked from rickydazla/retina-logo.html
Created April 14, 2014 06:47
Show Gist options
  • Save CameronGilroy/10622155 to your computer and use it in GitHub Desktop.
Save CameronGilroy/10622155 to your computer and use it in GitHub Desktop.
<a href="{{ shop.url }}">
<img
src="{{ 'logo.png' | asset_url }}"
alt="{{ shop.name }}"
data-retina-src="{{ 'logo.svg' | asset_url }}">
</a>
<script type="text/javascript">
Modernizr.addTest('retina', function () {
return (!!navigator.userAgent.match(/Macintosh|Mac|iPhone|iPad/i) && window.devicePixelRatio==2);
});
Modernizr.load([
{
test : Modernizr.retina,
yep : '{{ "jquery-retinadisplay.js" | asset_url }}', // https://github.com/gavroche/jquery-retinadisplay
complete : function () {
if(Modernizr.retina) {
$('img[data-retina-src]').retinaDisplay();
}
}
}
]);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment