]> cat aescling's git repositories - mastodon.git/commitdiff
Use srcSet only when know width (#4112)
authorYamagishi Kazutoshi <ykzts@desire.sh>
Sat, 8 Jul 2017 15:20:53 +0000 (00:20 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Sat, 8 Jul 2017 15:20:53 +0000 (17:20 +0200)
app/javascript/mastodon/components/media_gallery.js

index 2cb1ce51c809219533feadb63135f69b118a4735..75222e9650a4c3b9dc9e726c874ff96e88873579 100644 (file)
@@ -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