Skip to content

Commit

Permalink
MWPW-146743 - Fix get image caption (#54)
Browse files Browse the repository at this point in the history
* Removes returning 'undefined' which shows up in the DOM when a figure is not wrapped around the image

* Returning ''

---------

Co-authored-by: Megan Thomas <[email protected]>
  • Loading branch information
JasonHowellSlavin and meganthecoder authored Jun 20, 2024
1 parent 7dbed17 commit 20f6fef
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions blog/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,9 @@ function getImageCaption(picture) {

// If the parent element doesn't have a caption, check if the next sibling does
const parentSiblingEl = parentEl.nextElementSibling;
if (!parentSiblingEl || !parentSiblingEl.querySelector('picture')) return undefined;
if (!parentSiblingEl || !parentSiblingEl.querySelector('picture')) return '';
const firstChildEl = parentSiblingEl.firstChild;
caption = firstChildEl?.tagName === 'EM' ? firstChildEl : undefined;
return caption;
if (firstChildEl?.tagName === 'EM') return firstChildEl;
}

async function buildArticleHeader(el) {
Expand Down

0 comments on commit 20f6fef

Please sign in to comment.