Skip to content

Instantly share code, notes, and snippets.

@rickydazla
Last active March 10, 2016 02:04
Show Gist options
  • Save rickydazla/7323342 to your computer and use it in GitHub Desktop.
Save rickydazla/7323342 to your computer and use it in GitHub Desktop.
Shopify Retina SVG logo switcheroo_modernizr
<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