Skip to content

Instantly share code, notes, and snippets.

@thunsaker
Created February 11, 2011 16:58
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 thunsaker/822655 to your computer and use it in GitHub Desktop.
Save thunsaker/822655 to your computer and use it in GitHub Desktop.
Code to check the current device width and resize the image if it is too wide.
function reformatImages() {
$(document).ready(function () {
$('#div_content_inner_wrapper img').each(function () {
if ($(this).width() > $('body').width()) {
var newWidth = $('body').width() - 30;
$(this).css('width', newWidth);
}
$(this).css("border", "solid 1px gray");
$(this).css("padding", "2px");
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment