diff options
author | Yamagishi Kazutoshi <ykzts@desire.sh> | 2017-07-09 00:20:53 +0900 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-07-08 17:20:53 +0200 |
commit | 852bda3d320563400eaa74f02ef0c6c73cd8180d (patch) | |
tree | dc90f0346f21a2458640a57cc6a6bf63d471ec52 /app/javascript | |
parent | 0324f807f4f7b557bb0c38f0dbb4cfd98490957d (diff) |
Use srcSet only when know width (#4112)
Diffstat (limited to 'app/javascript')
-rw-r--r-- | app/javascript/mastodon/components/media_gallery.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/app/javascript/mastodon/components/media_gallery.js b/app/javascript/mastodon/components/media_gallery.js index 2cb1ce51c..75222e965 100644 --- a/app/javascript/mastodon/components/media_gallery.js +++ b/app/javascript/mastodon/components/media_gallery.js @@ -91,8 +91,10 @@ class Item extends React.PureComponent { const originalUrl = attachment.get('url'); const originalWidth = attachment.getIn(['meta', 'original', 'width']); - const srcSet = `${originalUrl} ${originalWidth}w, ${previewUrl} ${previewWidth}w`; - const sizes = `(min-width: 1025px) ${320 * (width / 100)}px, ${width}vw`; + const hasSize = typeof originalWidth === 'number' && typeof previewWidth === 'number'; + + const srcSet = hasSize && `${originalUrl} ${originalWidth}w, ${previewUrl} ${previewWidth}w`; + const sizes = hasSize && `(min-width: 1025px) ${320 * (width / 100)}px, ${width}vw`; thumbnail = ( <a |