Skip to content

Commit

Permalink
Fix bug with <picture><img eleventy:ignore> #214
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Jan 6, 2025
1 parent 4f6a6ba commit a40fd6c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/transform-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ function eleventyImageTransformPlugin(eleventyConfig, options = {}) {
match.call(pictureNode, { tag: 'img' }, imgNode => {
imgNode._insideOfPicture = true;

promises.push(transformTag(context, imgNode, pictureNode, opts));
if(!isIgnored(imgNode) && !imgNode?.attrs?.src?.startsWith("data:")) {
promises.push(transformTag(context, imgNode, pictureNode, opts));
}

return imgNode;
});
Expand All @@ -177,10 +179,10 @@ function eleventyImageTransformPlugin(eleventyConfig, options = {}) {
});

tree.match({ tag: 'img' }, (imgNode) => {
if(imgNode._insideOfPicture || isIgnored(imgNode) || imgNode?.attrs?.src?.startsWith("data:")) {
cleanTag(imgNode);

if(imgNode._insideOfPicture) {
delete imgNode._insideOfPicture;
} else if(isIgnored(imgNode) || imgNode?.attrs?.src?.startsWith("data:")) {
cleanTag(imgNode);
} else {
promises.push(transformTag(context, imgNode, imgNode, opts));
}
Expand Down

0 comments on commit a40fd6c

Please sign in to comment.