fix: file size and full screen

We are still using render media for images, so just adding it to the types makes the f button work. Feel free to remove if you think we aren't using render media for images (they seem to still work after adding that)
This commit is contained in:
Thomas Zarebczan 2019-07-24 01:23:35 -04:00 committed by Sean Yesmunt
parent 553ce44b8e
commit f47ea91415
2 changed files with 23 additions and 1 deletions

View file

@ -25,6 +25,9 @@ class FileDetails extends PureComponent<Props> {
const { description, languages, license } = metadata;
const mediaType = contentType || 'unknown';
const fileSize = metadata.source.size
? formatBytes(metadata.source.size)
: fileInfo && fileInfo.download_path && formatBytes(fileInfo.written_bytes);
let downloadPath = fileInfo && fileInfo.download_path ? path.normalize(fileInfo.download_path) : null;
let downloadNote;
// If the path is blank, file is not avialable. Create path from name so the folder opens on click.
@ -50,6 +53,13 @@ class FileDetails extends PureComponent<Props> {
{': '}
{mediaType}
</div>
{fileSize && (
<div>
{__('File Size')}
{': '}
{fileSize}
</div>
)}
<div>
{__('Languages')}
{': '}
@ -81,5 +91,17 @@ class FileDetails extends PureComponent<Props> {
);
}
}
// move this with other helper functions when we re-use it
function formatBytes(bytes, decimals = 2) {
if (bytes === 0) return '0 Bytes';
const k = 1024;
const dm = decimals < 0 ? 0 : decimals;
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
}
export default FileDetails;

View file

@ -316,7 +316,7 @@ class MediaPlayer extends React.PureComponent<Props, State> {
playableType(): boolean {
const { mediaType } = this.props;
return ['audio', 'video'].indexOf(mediaType) !== -1;
return ['audio', 'video', 'image'].indexOf(mediaType) !== -1;
}
isRenderMediaSupported() {