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:
parent
553ce44b8e
commit
f47ea91415
2 changed files with 23 additions and 1 deletions
|
@ -25,6 +25,9 @@ class FileDetails extends PureComponent<Props> {
|
||||||
const { description, languages, license } = metadata;
|
const { description, languages, license } = metadata;
|
||||||
|
|
||||||
const mediaType = contentType || 'unknown';
|
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 downloadPath = fileInfo && fileInfo.download_path ? path.normalize(fileInfo.download_path) : null;
|
||||||
let downloadNote;
|
let downloadNote;
|
||||||
// If the path is blank, file is not avialable. Create path from name so the folder opens on click.
|
// 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}
|
{mediaType}
|
||||||
</div>
|
</div>
|
||||||
|
{fileSize && (
|
||||||
|
<div>
|
||||||
|
{__('File Size')}
|
||||||
|
{': '}
|
||||||
|
{fileSize}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<div>
|
<div>
|
||||||
{__('Languages')}
|
{__('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;
|
export default FileDetails;
|
||||||
|
|
|
@ -316,7 +316,7 @@ class MediaPlayer extends React.PureComponent<Props, State> {
|
||||||
|
|
||||||
playableType(): boolean {
|
playableType(): boolean {
|
||||||
const { mediaType } = this.props;
|
const { mediaType } = this.props;
|
||||||
return ['audio', 'video'].indexOf(mediaType) !== -1;
|
return ['audio', 'video', 'image'].indexOf(mediaType) !== -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
isRenderMediaSupported() {
|
isRenderMediaSupported() {
|
||||||
|
|
Loading…
Reference in a new issue