Use srcSet only when know width (#4112)

lolsob-rspec
Yamagishi Kazutoshi 2017-07-09 00:20:53 +09:00 committed by Eugen Rochko
parent 01b589522e
commit aaa7f3ff41
1 changed files with 4 additions and 2 deletions

View 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