Created
October 6, 2017 11:28
-
-
Save Kcko/49a6563389682001f54c2c9bf172c1c7 to your computer and use it in GitHub Desktop.
Wrap image with caption
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(".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