Skip to content

Commit

Permalink
Fix issue with default attributes removed after use. #208
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Feb 10, 2024
1 parent e89e0c1 commit 9ed57b7
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/imageAttributesToPosthtmlNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ function convertToPosthtmlNode(obj) {
}

async function imageAttributesToPosthtmlNode(attributes, instanceOptions, globalPluginOptions) {

if(!attributes.src) {
throw new Error("Missing `src` attribute for `@11ty/eleventy-img`");
}
Expand All @@ -39,9 +38,6 @@ async function imageAttributesToPosthtmlNode(attributes, instanceOptions, global
throw new Error("Missing global defaults for `@11ty/eleventy-img`: did you call addPlugin?")
}

let defaultGlobalAttributes = globalPluginOptions.defaultAttributes;
delete globalPluginOptions.defaultAttributes;

if(!instanceOptions) {
instanceOptions = {};
}
Expand All @@ -63,7 +59,7 @@ async function imageAttributesToPosthtmlNode(attributes, instanceOptions, global

let options = Object.assign({}, globalPluginOptions, instanceOptions);
let metadata = await eleventyImage(attributes.src, options);
let imageAttributes = Object.assign({}, defaultGlobalAttributes, attributes);
let imageAttributes = Object.assign({}, globalPluginOptions.defaultAttributes, attributes);

// You bet we throw an error on missing alt in `imageAttributes` (alt="" works okay)
let obj = await eleventyImage.generateObject(metadata, imageAttributes);
Expand Down

0 comments on commit 9ed57b7

Please sign in to comment.