Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Kcko
Created October 6, 2017 11:28
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 Kcko/49a6563389682001f54c2c9bf172c1c7 to your computer and use it in GitHub Desktop.
Save Kcko/49a6563389682001f54c2c9bf172c1c7 to your computer and use it in GitHub Desktop.
Wrap image with caption
$(".img-left, .img-right, .article-detail img", this).each(function()
{
var image = $(this);
var imageCaption = image.attr("alt");
if (imageCaption != '')
{
image.wrap('<div class="image-w-caption">');
image.parent('.image-w-caption')
.css('max-width', image.width())
.addClass(image.attr('class'))
.append('<div class="caption">'+imageCaption+'</div>');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment