Skip to content

Instantly share code, notes, and snippets.

View zoe-edwards's full-sized avatar

Zoe Edwards zoe-edwards

View GitHub Profile
@zoe-edwards
zoe-edwards / hidpi-data
Created May 24, 2012 20:43
Detect high-DPI and use data-hidpi to replace img src
// Are we using a hidpi screen?
var hidpi = window.devicePixelRatio > 1 ? true : false;
if (hidpi) {
// Replace img src with data-hidpi
$('img[data-hidpi]').each(function() {
// If width x height hasn't been set, fill it in
if ($(this).attr('width') == undefined) {
$(this).attr('width', $(this).width());
}
if ($(this).attr('height') == undefined) {