Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add avif format support to gatsby remark images package #28927

Merged

Conversation

AlexRAV
Copy link
Contributor

@AlexRAV AlexRAV commented Jan 8, 2021

Description

Improvement of gatsby remark images package to support AVIF image format.

Documentation

Feature description added to Readme.md

Related Issues

#28894

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jan 8, 2021
></span>
<picture>
<source
srcset=\\"not-a-real-dir/images/my-image.jpeg, not-a-real-dir/images/my-image.jpeg\\"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't there be an avif image here?

Copy link
Contributor Author

@AlexRAV AlexRAV Jan 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's okay, because jest mocked fluid function here.

fluid({ file, args }) {
return Promise.resolve({
aspectRatio: 0.75,
presentationWidth: 300,
originalImg: file.absolutePath,
src: file.absolutePath,
srcSet: `${file.absolutePath}, ${file.absolutePath}`,
sizes: `(max-width: ${args.maxWidth}px) 100vw, ${args.maxWidth}px`,
base64: `data:image/png;base64,iVBORw`,
})
},

This function just returns the string with absolute paths in it as srcSet, without format transform.

Copy link
Contributor

@KyleAMathews KyleAMathews left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally & works great. Thanks!

@KyleAMathews KyleAMathews merged commit 0cb68df into gatsbyjs:master Jan 9, 2021
@LekoArts LekoArts removed the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jan 11, 2021
@gupta-ji6
Copy link

gupta-ji6 commented Jan 27, 2021

Hi @AlexRAV @LekoArts, gatsby develop still shows this warning with withAvif option enabled.

image

Config

{
            resolve: 'gatsby-remark-images',
            options: {
              maxWidth: 900,
              showCaptions: true,
              markdownCaptions: true,
              linkImagesToOriginal: false,
              quality: 90,
              // tracedSVG: { color: config.greenColor },
              wrapperStyle: `border-radius: 3px; margin: 10px 0; text-align: center;`,
              backgroundColor: 'transparent',
              withWebp: true,
              withAvif: true,
            },
}

Version

    "gatsby": "2.30.3",
    "gatsby-plugin-sharp": "2.13.2",
    "gatsby-remark-images": "3.10.0",
    "gatsby-transformer-remark": "2.3.8",
    "gatsby-transformer-sharp": "2.1.18",

@abarisain
Copy link
Contributor

I think that the schema hasn't been updated https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-remark-images/src/gatsby-node.js#L51

@gupta-ji6
Copy link

I think that the schema hasn't been updated https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-remark-images/src/gatsby-node.js#L51

I see 👀.

Happy to make a PR for the official docs if this is the case.

pragmaticpat pushed a commit to pragmaticpat/gatsby that referenced this pull request Apr 28, 2022
* Add avif format support to gatsby remark images package

* Add withAvif info into readme

* Add devault value for withAvif option

* Updated snapshot

* Added test for withAvif option
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants