Skip to content

How to opt out the animated option only for jpeg outputs? #3208

Answered by tkrhub
tkrhub asked this question in Q&A
Discussion options

You must be logged in to vote

I figured out a solution working for me.
Since I'm using markdown-it-eleventy-img and it overrides eleventy-img's options, I modified index.js in the markdown-it-eleventy-img folder.

    // Checking an input file extension.
    // If it is gif, ONLY output a webp file by redefining the "formats" option.
    var fileExtension = src.split(".").pop();
    if (fileExtension == "gif")
    {      
      const webpArray = ["webp"];
      imgOptions.formats = webpArray;
    }

This is NOT checking whether a gif file is static or animated but this works for me because I only use animated gifs. That's the case for most of people too I assume. You can change sharpOptions: {animated: true/false} inst…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by tkrhub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant