-
-
Save kriscarle/470cb1f0cb36415147ce to your computer and use it in GitHub Desktop.
display image caption in DNN using longdesc img attribute
This file contains 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
$('.ModDNNHTMLC img').each(function(i) { | |
var img = $(this), | |
width = $(this).css('width'), | |
imageCaption = $(this).attr('longdesc'), | |
figure | |
if(imageCaption){ | |
if (img.css('float') == 'left') { | |
img.css('float', ''); | |
figure = $('<figure class="alignleft"></figure>').css('width', width).css('float', 'left'); | |
img.wrap(figure); | |
img.parent('figure').append('<figcaption>' + imageCaption + '</figcaption>'); | |
} else if (img.css('float') == 'right') { | |
img.css('float', ''); | |
figure = $('<figure class="alignright"></figure>').css('width', width).css('float', 'right'); | |
img.wrap(figure); | |
img.parent('figure').append('<figcaption>' + imageCaption + '</figcaption>'); | |
} else { | |
img.css('float', ''); | |
figure = $('<figure class="alignright"></figure>').css('width', width).css('float', 'right'); | |
img.wrap(figure); | |
img.parent('figure').append('<figcaption>' + imageCaption + '</figcaption>'); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated to support DNN 7 only modifying images inside the HTML module. Also automatically adds the float right/left directing to the figure tag.