Skip to content

Instantly share code, notes, and snippets.

@mattonomics
Last active December 15, 2015 03:09
Show Gist options
  • Save mattonomics/5192165 to your computer and use it in GitHub Desktop.
Save mattonomics/5192165 to your computer and use it in GitHub Desktop.
function adjust_caption() {
var captions = document.getElementsByClassName('wp-caption');
for (var i = 0; i < captions.length; i++) {
// set wrap to auto
captions[i].style.width = 'auto';
// will set the width of the p to the same as the image. comment out if you don't want/need
captions[i].getElementsByTagName('p')[0].style.width = captions[i].getElementsByTagName('img')[0].width + 'px';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment