Skip to content

Instantly share code, notes, and snippets.

@mtigas
Created July 13, 2012 20:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtigas/3107092 to your computer and use it in GitHub Desktop.
Save mtigas/3107092 to your computer and use it in GitHub Desktop.
<!--somewhere in the headers or in a site-wide JS file or right before you need a retina snippet -->
<script>var SR=SR||{};SR.RETINA=((window.devicePixelRatio !== undefined)&&(window.devicePixelRatio >= 2));</script>
{% comment %}an image where we use "mogrify" to set an explicit width/height{% endcomment %}
{% spaceless %}<a class="nohlt" href="{{ item.url }}">
<script type="text/javascript">
if (SR.RETINA) {
document.write('<img id="lead-art-top" class="lead-art" src="{% mogrify item.photo.url resize "760x420" %}" style="width:380px;height:210px" />');
} else {
document.write('<img id="lead-art-top" class="lead-art" src="{% mogrify item.photo.url resize "380x210" %}" style="width:380px;height:210px" />');
}
</script><noscript>
<img id="lead-art-top" class="lead-art" src="{% mogrify item.photo.url resize "380x210" %}" style="width:380px;height:210px" />
</noscript></a>{% endspaceless %}
{% comment %}an image where we use "mogrify" to set only explicit width{% endcomment %}
{% spaceless %}<script type="text/javascript">
if (SR.RETINA) {
document.write('<img style="width:460px" src="{% mogrify item.image.url thumbnail "940" %}" oncontextmenu="return false;" onmousedown="return false;" onmousemove="return false;" />');
} else {
document.write('<img style="width:460px" src="{% mogrify item.image.url thumbnail "460" %}" oncontextmenu="return false;" onmousedown="return false;" onmousemove="return false;" />');
}
</script><noscript><img style="width:460px" src="{% mogrify item.image.url thumbnail "460" %}" oncontextmenu="return false;" onmousedown="return false;" onmousemove="return false;" /></noscript>{% endspaceless %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment