Fix images being shown as unsupported formats in viewer

This commit is contained in:
Will Abson
2016-06-10 11:31:37 +01:00
parent a91f563004
commit eba56e22a8
2 changed files with 16 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
{ {
"name": "ng2-alfresco-viewer", "name": "ng2-alfresco-viewer",
"description": "Alfresco documents viewer", "description": "Alfresco documents viewer",
"version": "0.1.14", "version": "0.1.15",
"author": "Eugenio Romano", "author": "Eugenio Romano",
"scripts": { "scripts": {
"typings": "typings install", "typings": "typings install",

View File

@@ -105,19 +105,30 @@ export class ViewerComponent {
return fileName.split('.').pop().toLowerCase(); return fileName.split('.').pop().toLowerCase();
} }
/**
* check if the current file is a suppoerted image extension
*/
private isImage() { private isImage() {
return this.isImageExtension() || this.isImageMimeType();
}
/**
* check if the current file is a supported image extension
*/
private isImageExtension() {
return this.extension === 'png' || this.extension === 'jpg' || return this.extension === 'png' || this.extension === 'jpg' ||
this.extension === 'jpeg' || this.extension === 'gif' || this.extension === 'bmp'; this.extension === 'jpeg' || this.extension === 'gif' || this.extension === 'bmp';
} }
/**
* check if the current file has an image-based mimetype
*/
private isImageMimeType() {
return this.mimeType !== null && this.mimeType.indexOf('image/') === 0;
}
/** /**
* check if the current file is a suppoerted pdf extension * check if the current file is a suppoerted pdf extension
*/ */
private isPdf() { private isPdf() {
return this.extension === 'pdf' || this.mimeType == 'application/pdf'; return this.extension === 'pdf' || this.mimeType === 'application/pdf';
} }
/** /**