[#1548] added PDF preview

This commit is contained in:
mjadobson
2023-01-09 19:41:27 +00:00
committed by GitHub
parent c1ff1c6155
commit 7459c9208f
36 changed files with 175 additions and 132 deletions
+22
View File
@@ -663,6 +663,28 @@ export default class CommonHelper {
return /\.jpg|\.jpeg|\.png|\.svg|\.gif|\.jfif|\.webp|\.avif$/.test(filename)
}
/**
* Loosely check if a file is a pdf based on its filename extension.
*
* @param {String} filename
* @return {Boolean}
*/
static hasPdfExtension(filename) {
return /\.pdf$/.test(filename);
}
/**
* Returns file type
*
* @param {String} filename
* @return {String}
*/
static getFileType(filename) {
if (this.hasImageExtension(filename)) return "image";
if (this.hasPdfExtension(filename)) return "pdf";
return "file";
}
/**
* Creates a thumbnail from `File` with the specified `width` and `height` params.
* Returns a `Promise` with the generated base64 url.