Skip to content

Commit

Permalink
Merge pull request #195 from GHF/gif-lowsrc
Browse files Browse the repository at this point in the history
Generate gif as lowest priority source
  • Loading branch information
zachleat authored Jan 15, 2024
2 parents baea57d + cb523b7 commit 1ab4211
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion generate-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const DEFAULT_ATTRIBUTES = {
// decoding: "async",
};

const LOWSRC_FORMAT_PREFERENCE = ["jpeg", "png", "svg", "webp", "avif"];
const LOWSRC_FORMAT_PREFERENCE = ["gif", "jpeg", "png", "svg", "webp", "avif"];

/*
Returns:
Expand Down
13 changes: 12 additions & 1 deletion test/test-markup.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,18 @@ test("Image markup (animated gif)", async t => {
test("Image markup (animated gif, two formats)", async t => {
let results = await eleventyImage("./test/earth-animated.gif", {
dryRun: true,
formats: ["tiff", "auto"]
formats: ["webp", "auto"]
});

t.is(generateHTML(results, {
alt: ""
}), `<picture><source type="image/webp" srcset="/img/YQVTYq1wRQ-400.webp 400w"><img alt="" src="/img/YQVTYq1wRQ-400.gif" width="400" height="400"></picture>`);
});

test("Image markup (two formats, neither priority defined)", async t => {
let results = await eleventyImage("./test/earth-animated.gif", {
dryRun: true,
formats: ["tif", "heic"]
});

let e = t.throws(() => generateHTML(results, { alt: "" }));
Expand Down

0 comments on commit 1ab4211

Please sign in to comment.