Dopus 12.22.1b implemented the following change to DOpus.LoadThumbnail
- The DOpus.LoadThumbnail scripting method now requests thumbnails from OneDrive (etc.) for offline files, instead of causing the files to be downloaded for thumbnail generation.
This change works perfectly for everything else I have tried but not for Office files (.docx, .xlsx) on OneDrive, whether or not they are available locally. The attached test button cycles through selected (or all) files and either loads an image preview or a thumbnail for non-image files. By default, it allows up to 500ms for a thumbnail to load. On my system I have to increase the delay to 12500ms in order for Word or Excel thumbnails to appear. Other thumbnails (.txt, .zip, .pdf) appear instantly and in non-OneDrive folders Office file thumbnails also appear instantly.
Test code is appended for info. The .dcf file contains the relevant dialog template. Increase the delay by selectively uncommenting the var msThumbLoad = nnnn statements.
LoadThumb.dcf (5.1 KB)
// Global variables
var dlg = DOpus.dlg, msg_obj;
// Button code
function OnClick(clickData)
{
// --------------------------------------------------------
//DOpus.ClearOutput();
// --------------------------------------------------------
var cmd = clickData.func.command;
cmd.deselect = false; // Prevent automatic deselection
// --------------------------------------------------------
var currTab = DOpus.listers.lastactive.activetab;
var candidates = (currTab.selected_files.count===0) ? currTab.files : currTab.selected_files;
if (candidates.count==0) return; // No files to process
// --------------------------------------------------------
dlg.window = DOpus.listers.lastactive; // Lock the dialog to the active lister
dlg.template = "dlg1"; // Set the correct dialog template
dlg.detach = true;
dlg.title = "LoadThumb Test";
dlg.create;
var n = 0;
loadNextFile(candidates(n++));
// --------------------------------------------------------
do{
msg_obj = dlg.getmsg();
if (msg_obj==false) break;
if (n==candidates.count) n = 0;
if (msg_obj.event=="click") loadNextFile(candidates(n++));
}
while (msg_obj);
// --------------------------------------------------------
}
function loadNextFile(currItem)
{
// --------------------------------------------------------
var isImage = (currItem.metadata=="image");
var rotItem = (isImage) ? currItem.metadata.image.rotation : 0;
var rotAdjust = (typeof rotItem=="string") ? 0 - rotItem : 0;
var msThumbLoad = 500;
//var msThumbLoad = 5000;
//var msThumbLoad = 10000;
//var msThumbLoad = 12500;
dlg.Control("grpPreview").label = currItem;
if (isImage) {
if (rotAdjust!=0) dlg.Control("staticImage").visible = false;
else dlg.Control("staticImage").label = DOpus.LoadImage(currItem,400,400);
dlg.Control("staticImage").rotate = rotAdjust;
dlg.Control("staticImage").visible = true;
}
else {
dlg.Control("staticImage").rotate = 0;
dlg.Control("staticImage").label = DOpus.LoadThumbnail(currItem,msThumbLoad);
}
// --------------------------------------------------------
}