MediaGallery: fix audio attachment thumb crash

This commit is contained in:
Alex Gleason 2021-10-12 13:46:09 -05:00
parent 135ec190ee
commit 583aa6fd60
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -197,21 +197,18 @@ class Item extends React.PureComponent {
</div> </div>
); );
} else if (attachment.get('type') === 'audio') { } else if (attachment.get('type') === 'audio') {
const remoteURL = attachment.get('remote_url'); const ext = attachment.get('url').split('.').pop().toUpperCase();
const originalUrl = attachment.get('url');
const fileExtensionLastIndex = remoteURL.lastIndexOf('.');
const fileExtension = remoteURL.substr(fileExtensionLastIndex + 1).toUpperCase();
thumbnail = ( thumbnail = (
<a <a
className={classNames('media-gallery__item-thumbnail')} className={classNames('media-gallery__item-thumbnail')}
href={attachment.get('remote_url') || originalUrl} href={attachment.get('url')}
onClick={this.handleClick} onClick={this.handleClick}
target='_blank' target='_blank'
alt={attachment.get('description')} alt={attachment.get('description')}
title={attachment.get('description')} title={attachment.get('description')}
> >
<span className='media-gallery__item__icons'><Icon id='volume-up' /></span> <span className='media-gallery__item__icons'><Icon id='volume-up' /></span>
<span className='media-gallery__file-extension__label'>{fileExtension}</span> <span className='media-gallery__file-extension__label'>{ext}</span>
</a> </a>
); );
} else if (attachment.get('type') === 'video') { } else if (attachment.get('type') === 'video') {