Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 8dc4127

Browse files
authored
Add srcset support to CImage
Fixes #422
1 parent 782fecd commit 8dc4127

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/chakra-ui-core/src/CImage/CImage.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const CImage = {
2525
mixins: [createStyledAttrsMixin('CImage')],
2626
props: {
2727
src: String,
28+
srcset: String,
2829
fallbackSrc: String,
2930
ignoreFalback: Boolean,
3031
htmlWidth: String,
@@ -48,12 +49,13 @@ const CImage = {
4849
created () {
4950
// Should only invoke window.Image in the browser.
5051
if (process.browser) {
51-
this.loadImage(this.src)
52+
this.loadImage(this.src, this.srcset)
5253
}
5354
},
5455
methods: {
55-
loadImage (src) {
56+
loadImage (src, srcset) {
5657
const image = new window.Image()
58+
image.srcset = srcset
5759
image.src = src
5860

5961
image.onload = (event) => {

0 commit comments

Comments
 (0)