Skip to content

Commit

Permalink
Add lint rule to detect non-AVIF images (#2557)
Browse files Browse the repository at this point in the history
Includes instructions on how to convert images to AVIF.
  • Loading branch information
frankharkins authored Jan 9, 2025
1 parent a26edc2 commit 11c6beb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions scripts/js/lib/markdownImages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ export async function collectInvalidImageErrors(
if (!node.alt || node.alt.endsWith(imageName!)) {
imagesErrors.add(`The image '${node.url}' does not have alt text.`);
}
// Remove `false &&` when ready to switch to AVIF
if (false && node.url.match(/\.(png|jpe?g)$/)) {
const urlWithAvifExtension = node.url.replace(
/\.(png|jpe?g)$/,
".avif",
);
imagesErrors.add(
`Convert '${imageName}' to AVIF. You can use the command \`magick public${node.url} public${urlWithAvifExtension}\`. ` +
`If ImageMagick isn't preinstalled, you can get it from https://imagemagick.org/script/download.php. ` +
`Then delete the old file and update the markdown to point to the new file.`,
);
}
});
visit(tree, "html", (node) => {
const $ = load(node.value);
Expand Down

0 comments on commit 11c6beb

Please sign in to comment.