Skip to content

Instantly share code, notes, and snippets.

@ingozoell
Created November 3, 2013 13:25
Show Gist options
  • Save ingozoell/7290259 to your computer and use it in GitHub Desktop.
Save ingozoell/7290259 to your computer and use it in GitHub Desktop.
Remove image height and width attribute excerpt for HiDPI/Retina devices
#hidpi { position: relative; display: none; z-index: 0;}
/* Hidpi/Retina Check
/* https://gist.github.com/sergejmueller/2642698 */
@media (-o-min-device-pixel-ratio: 5/4),
(-webkit-min-device-pixel-ratio: 1.25),
(min-resolution: 120dpi) {
#hidpi { display: none; position: relative; z-index: -1; }
}
<body>
<div id="hidpi"></div>
...
</body>
var $is_hidpi = false; // Global var
if( $('#hidpi').css('z-index') == '-1' ) {
$is_hidpi = true;
}
$(document).ready(function() {
if(!$is_hidpi) {
$('img').each(function(){
$(this).removeAttr('width')
$(this).removeAttr('height');
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment