Skip to content

Commit

Permalink
Merge pull request #7 from kroppenstedt/patch-4
Browse files Browse the repository at this point in the history
Update api.js
  • Loading branch information
EdwardBock committed Jun 23, 2020
2 parents 77714fe + 73c526b commit ffbc976
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions js/api.js
Expand Up @@ -78,6 +78,8 @@
function process_image(element, caption) {

var $img = $(element);
var $figure = $("<figure></figure>")
.addClass("wp-caption media-license__figure");


if($img.hasClass("alignright")){
Expand All @@ -102,8 +104,17 @@
$img.parent().addClass("media-license__figure");
}

var $figure = $("<figure></figure>")
.addClass("wp-caption media-license__figure");
if( ! $img.parent().has("figcaption") ) {
var $caption = $("<figcaption>"+caption+"</figcaption>").addClass("wp-caption-text media-license__figcaption");
// image is wrapped with link
if( $img.parent("a").length == 1 ) {
$img.next("figure").append($caption);
} else {
$img.after($caption);
}
} else {
$img.parent().find("figcaption").addClass("media-license__figcaption").html( caption );
}

if ($img.hasClass("alignright")) {
$figure.addClass("alignright");
Expand Down

0 comments on commit ffbc976

Please sign in to comment.