Skip to content

Instantly share code, notes, and snippets.

@micah1701
Last active May 5, 2016 03:27
Show Gist options
  • Save micah1701/f83c82165518ee8f9574bb0cb3c82ce7 to your computer and use it in GitHub Desktop.
Save micah1701/f83c82165518ee8f9574bb0cb3c82ce7 to your computer and use it in GitHub Desktop.
Make all user uploaded images responsive
// make all user uploaded images responsive
$(".user_uploaded_content_wrapper img").each(function(){
var oldWidth = ($(this).width() > 0) ? $(this).width()+"px" : '100%';
$(this).css({width:'100%', height:'auto', maxWidth:oldWidth});
});
@micah1701
Copy link
Author

micah1701 commented May 5, 2016

Note, requires an HTML "width" parameter be set on the image if the max-width needs to be less than 100%. (eg, an icon or an image that floats within the copy, even at mobile)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment