Skip to content

TagSpaces is an offline, open source, document manager with tagging support

TS120 - generate thumbnails

Borislav Sapundzhiev1e477cc74eab
diff --git a/data/ext/perspectiveGrid/perspectiveUI.js b/data/ext/perspectiveGrid/perspectiveUI.js
index 83d2c4c9b..07887e4a8 100644
--- a/data/ext/perspectiveGrid/perspectiveUI.js
+++ b/data/ext/perspectiveGrid/perspectiveUI.js
@@ -271,8 +271,15 @@ define(function(require, exports, module) {
ExtUI.prototype.enableThumbnails = function() {
$("#" + this.extensionID + "IncreaseThumbsButton").prop('disabled', false);
$("#" + this.extensionID + "Container .thumbImgTile").each(function() {
- generateThumbnail($(this).attr('filepath'), $(this));
- $(this).attr('style', "");
+ var $element = $(this);
+ if (TSPRO.available) {
+ TSPRO.getThumbnailURL($element.attr('filepath'), function(dataURL) {
+ $element.attr('src', dataURL);
+ });
+ } else {
+ generateThumbnail($element.attr('filepath'), $element);
+ }
+ $element.attr('style', "");
});
$('.thumbImgTile').css({
"max-width": TMB_SIZES[this.currentTmbSize],
diff --git a/data/node-webkit/node-webkit.api.js b/data/node-webkit/node-webkit.api.js
index 42978fa19..6cbb4a50e 100644
--- a/data/node-webkit/node-webkit.api.js
+++ b/data/node-webkit/node-webkit.api.js
@@ -621,16 +621,26 @@ define(function(require, exports, module) {
mtime: Mon, 10 Oct 2011 23:24:11 GMT,
ctime: Mon, 10 Oct 2011 23:24:11 GMT
*/
- var getFileProperties = function(filePath) {
+ var getFileProperties = function(filePath, result) {
var fileProperties = {};
- var stats = fs.lstatSync(filePath);
- if (stats.isFile()) {
- fileProperties.path = filePath;
- fileProperties.size = stats.size;
- fileProperties.lmdt = stats.mtime;
- TSPOSTIO.getFileProperties(fileProperties);
- } else {
- console.warn("Error getting file properties. " + filePath + " is directory");
+ try {
+ var stats = fs.lstatSync(filePath);
+ if (stats.isFile()) {
+ fileProperties.path = filePath;
+ fileProperties.size = stats.size;
+ fileProperties.lmdt = stats.mtime;
+ if (resultCb) {
+ result(fileProperties);
+ } else {
+ TSPOSTIO.getFileProperties(fileProperties);
+ }
+ } else {
+ console.warn("Error getting file properties. " + filePath + " is directory");
+ }
+ } catch (e) {
+ if(result) {
+ result(false);
+ }
}
};