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