Skip to content

Instantly share code, notes, and snippets.

@conspirator
Created July 11, 2014 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save conspirator/24943de7ee44d293877c to your computer and use it in GitHub Desktop.
Save conspirator/24943de7ee44d293877c to your computer and use it in GitHub Desktop.
jQuery(function(){
if (window.matchMedia) {
if (window.matchMedia("(max-device-width: 480px)").matches) {
jQuery('.mobile-src').each(function(){
var $el = jQuery(this),
newSrc = $el.attr('src').split('?')[0] + "-mobile?fmt=png-alpha&qlt=95";
jQuery('<img>', {
'src': newSrc,
'load': function(){
$el.removeAttr('height width').attr({
'src': newSrc
})
}
});
})
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment