Skip to content

Commit

Permalink
fix(htmlimage): use src if srcset not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
Ondrej Base committed Jun 25, 2018
1 parent 1cfb47d commit 9d47983
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/image/HtmlImage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,13 @@ export default class HtmlImage extends React.PureComponent {
};
let { src, srcSet, sizes } = this.props;

if (sizes) {
image.sizes = sizes;
}
if (srcSet && this._areResponsiveImagesSupported()) {
if (sizes) {
image.sizes = sizes;
}

if (srcSet) {
image.srcset = srcSet;
}

if (src) {
} else if (src) {
image.src = src;
}

Expand All @@ -229,4 +227,10 @@ export default class HtmlImage extends React.PureComponent {
this.setState({ noloading: true, showLoader: false });
}
}

_areResponsiveImagesSupported() {
const img = new Image();

return 'srcset' in img && 'sizes' in img;
}
}

0 comments on commit 9d47983

Please sign in to comment.