1+ import { Image , ImageKitProvider , Video } from "@imagekit/react" ;
2+
3+
4+ export const Basic = ( ) => {
5+ return (
6+ < div >
7+ < h1 > Image</ h1 >
8+
9+ < Image
10+ urlEndpoint = "https://ik.imagekit.io/demo/"
11+ src = "default-image.jpg"
12+ alt = "Image without ImageKit provider"
13+ height = { 300 }
14+ width = { 300 }
15+ style = { { color : "red" } } // we add `color:red` styles in all Image because otherwise Next.js may add `color:transparent` styles to the image. This may causes flaky tests.
16+ />
17+
18+ < ImageKitProvider urlEndpoint = "https://ik.imagekit.io/demo/" >
19+ < Image
20+ src = "/default-image.jpg"
21+ alt = "Image with ImageKit provider"
22+ height = { 300 }
23+ width = { 300 }
24+ style = { { color : "red" } }
25+ />
26+
27+ < Image
28+ src = "/default-image.jpg"
29+ alt = "With transformation"
30+ transformation = { [ { height : 100 , width : 100 } ] }
31+ height = { 300 }
32+ width = { 300 }
33+ style = { { color : "red" } }
34+ />
35+
36+ { /* quality={50} */ }
37+ < Image
38+ src = "/default-image.jpg"
39+ alt = "Image with quality"
40+ quality = { 50 }
41+ transformation = { [ { height : 100 , width : 100 } ] }
42+ height = { 300 }
43+ width = { 300 }
44+ style = { { color : "red" } }
45+ />
46+
47+ < Image
48+ src = "/default-image.jpg"
49+ alt = "Image with queryParameters"
50+ queryParameters = { {
51+ version : "v1" ,
52+ } }
53+ transformation = { [ { height : 100 , width : 100 } ] }
54+ height = { 300 }
55+ width = { 300 }
56+ style = { { color : "red" } }
57+ />
58+
59+ { /* responsive images with sizes */ }
60+ < Image
61+ src = "/default-image.jpg"
62+ alt = "Responsive image with sizes"
63+ sizes = "(max-width: 600px) 100vw, 50vw"
64+ height = { 300 }
65+ width = { 300 }
66+ style = { { color : "red" } }
67+ />
68+
69+ { /* urlEndpoint override */ }
70+ < Image
71+ urlEndpoint = "https://ik.imagekit.io/demo2/"
72+ src = "/default-image.jpg"
73+ alt = "Image with urlEndpoint override"
74+ transformation = { [ { height : 100 , width : 100 } ] }
75+ height = { 300 }
76+ width = { 300 }
77+ style = { { color : "red" } }
78+ />
79+
80+ { /* Pass className to the image tag as it is */ }
81+ < Image
82+ src = "/default-image.jpg"
83+ alt = "Image with className"
84+ className = "custom-class"
85+ height = { 300 }
86+ width = { 300 }
87+ style = { { color : "red" } }
88+ />
89+
90+ { /* Lazy loading eager */ }
91+ < Image
92+ src = "/default-image.jpg"
93+ alt = "Image with lazy loading eager"
94+ loading = "eager"
95+ height = { 300 }
96+ width = { 300 }
97+ style = { { color : "red" } }
98+ />
99+
100+ { /* Transformation position test */ }
101+ < Image
102+ src = "/default-image.jpg"
103+ alt = "Image with path transformation"
104+ transformationPosition = "path"
105+ height = { 300 }
106+ width = { 300 }
107+ style = { { color : "red" } }
108+ />
109+
110+ < Image
111+ src = "https://ik.imagekit/demo/default-image.jpg"
112+ alt = "path not respected with absolute url"
113+ transformationPosition = "path"
114+ height = { 300 }
115+ width = { 300 }
116+ style = { { color : "red" } }
117+ />
118+
119+ { /* Responsive off */ }
120+ < Image
121+ src = "/default-image.jpg"
122+ alt = "Image with responsive off"
123+ height = { 300 }
124+ width = { 300 }
125+ transformation = { [ {
126+ named : "restrict-unnamed" ,
127+ } ] }
128+ style = { { color : "red" } }
129+ responsive = { false }
130+ sizes = "(max-width: 600px) 100vw, 50vw"
131+ />
132+
133+ </ ImageKitProvider >
134+
135+ < h1 > Video</ h1 >
136+
137+ < Video
138+ urlEndpoint = "https://ik.imagekit.io/demo/"
139+ src = "sample-video.mp4"
140+ title = "Video without ImageKit provider"
141+ height = { 300 }
142+ width = { 300 }
143+ controls = { true }
144+ />
145+
146+ { /* With ImageKit provider */ }
147+ < ImageKitProvider urlEndpoint = "https://ik.imagekit.io/demo/" >
148+ < Video
149+ src = "sample-video.mp4"
150+ title = "Video with ImageKit provider"
151+ height = { 300 }
152+ width = { 300 }
153+ controls = { true }
154+ />
155+
156+ { /* With transformations */ }
157+ < Video
158+ src = "sample-video.mp4"
159+ title = "Video with transformations"
160+ transformation = { [ { height : 100 , width : 100 } ] }
161+ height = { 300 }
162+ width = { 300 }
163+ controls = { true }
164+ />
165+
166+ { /* Passing all props to the video tag as it is */ }
167+ < Video
168+ src = "sample-video.mp4"
169+ title = "Video with all props"
170+ height = { 300 }
171+ width = { 300 }
172+ controls
173+ autoPlay
174+ loop
175+ muted
176+ playsInline
177+ preload = "none"
178+ poster = "https://ik.imagekit.io/demo/default-image.jpg"
179+ />
180+
181+ { /* urlEndpoint override */ }
182+ < Video
183+ urlEndpoint = "https://ik.imagekit.io/demo2/"
184+ src = "sample-video.mp4"
185+ title = "Video with urlEndpoint override"
186+ height = { 300 }
187+ width = { 300 }
188+ transformation = { [ { height : 100 , width : 100 } ] }
189+ controls = { true }
190+ />
191+ </ ImageKitProvider >
192+
193+ </ div >
194+ )
195+ }
0 commit comments