Show mimetype icon if version preview is not available

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2018-11-23 11:21:47 +01:00 committed by Roeland Jago Douma
parent 15a04ecaeb
commit c2f4297e49
No known key found for this signature in database
GPG Key ID: F941078878347C0C
1 changed files with 7 additions and 1 deletions

View File

@ -150,6 +150,12 @@
_formatItem: function(version) {
var timestamp = version.get('timestamp') * 1000;
var size = version.has('size') ? version.get('size') : 0;
var preview = OC.MimeType.getIconUrl(version.get('mimetype'));
var img = new Image();
img.onload = function () {
$('li[data-revision=' + version.get('timestamp') + '] .preview').attr('src', version.getPreviewUrl());
};
img.src = version.getPreviewUrl();
return _.extend({
versionId: version.get('id'),
@ -163,7 +169,7 @@
downloadIconUrl: OC.imagePath('core', 'actions/download'),
downloadName: version.get('name'),
revertIconUrl: OC.imagePath('core', 'actions/history'),
previewUrl: version.getPreviewUrl(),
previewUrl: preview,
revertLabel: t('files_versions', 'Restore'),
canRevert: (this.collection.getFileInfo().get('permissions') & OC.PERMISSION_UPDATE) !== 0
}, version.attributes);