Skip to content

Commit 2058775

Browse files
authored
feat: Add AVIF image support to beta image plugin (#28742)
* Upgrade sharp * Add avif support * Add avif e2e tests * Allow - but warn about - using just AVIF * Add missing AVIF gql type * Upgrade e2e test executor
1 parent 146b197 commit 2058775

21 files changed

+133
-20
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ executors:
2323
aliases:
2424
e2e-executor: &e2e-executor
2525
docker:
26-
- image: cypress/browsers:node10.16.0-chrome76
26+
- image: cypress/browsers:node12.18.3-chrome87-ff82
2727

2828
restore_cache: &restore_cache
2929
restore_cache:

e2e-tests/visual-regression/cypress/integration/image.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ const testCases = [
33
["fixed image smaller than requested size", "/images/fixed-too-big"],
44
["fluid image", "/images/fluid"],
55
["constrained image", "/images/constrained"],
6+
["avif format", "/images/avif"],
67
]
78
const staticImageTestCases = [
89
["fixed image", "/static-images/fixed"],
910
["fixed image smaller than requested size", "/static-images/fixed-too-big"],
1011
["fluid image", "/static-images/fluid"],
1112
["constrained image", "/static-images/constrained"],
13+
["avif format", "/static-images/avif"],
1214
]
1315

1416
const sizes = [["iphone-6"], ["ipad-2"], [1027, 768]]
578 KB
Loading
297 KB
Loading
67.9 KB
Loading
578 KB
Loading
297 KB
Loading
67.9 KB
Loading
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import * as React from "react"
2+
import { GatsbyImage, getImage } from "gatsby-plugin-image"
3+
import { useStaticQuery, graphql } from "gatsby"
4+
import { TestWrapper } from "../../components/test-wrapper"
5+
import Layout from "../../components/layout"
6+
7+
const Page = () => {
8+
const data = useStaticQuery(graphql`
9+
query {
10+
file(relativePath: { eq: "cornwall.jpg" }) {
11+
childImageSharp {
12+
gatsbyImageData(maxWidth: 1024, layout: CONSTRAINED, formats: [AVIF])
13+
}
14+
}
15+
}
16+
`)
17+
18+
return (
19+
<Layout>
20+
<h1>AVIF</h1>
21+
<TestWrapper>
22+
<GatsbyImage image={getImage(data.file)} alt="cornwall" />
23+
</TestWrapper>
24+
</Layout>
25+
)
26+
}
27+
28+
export default Page
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import * as React from "react"
2+
import { StaticImage } from "gatsby-plugin-image"
3+
import { TestWrapper } from "../../components/test-wrapper"
4+
import Layout from "../../components/layout"
5+
6+
const Page = () => {
7+
return (
8+
<Layout>
9+
<h1>AVIF</h1>
10+
<TestWrapper>
11+
<StaticImage
12+
src="../../images/cornwall.jpg"
13+
alt="cornwall"
14+
formats={["avif"]}
15+
maxWidth={1024}
16+
/>
17+
</TestWrapper>
18+
</Layout>
19+
)
20+
}
21+
22+
export default Page

0 commit comments

Comments
 (0)