Overview:
The add-in lets you tell Opus to load all thumbnails in specific folders, when you don't want to do so in all folders.
It usually only makes sense to install the add-in if you have turned off the Load all thumbnails in a folder automatically option:
On the other hand, if the option is on, Opus will load all thumbnails in all folders already, and the script probably isn't useful.
(There is one case where the script may still be useful with the option on: You can use it to pre-cache thumbnails when entering certain folders before switching into Thumbnails mode.)
When Load all thumbnails in a folder automatically is off, Opus only loads the thumbnails that are currently visible. This can help avoid extra background CPU, memory and disk contention, but also means there may be a short delay before thumbnails appear when you scroll them into view.
When Load all thumbnails in a folder automatically is on, Opus loads all thumbnails for a folder as soon as you switch into Thumbnails mode. The script can trigger the same thing for specified folders without needing the option to be turned on. The script can also, optionally, trigger thumbnail loading before switching into Thumbnails mode.
Installation:
- Requires Opus 12.17 or above.
- Download: LoadAllThumbnails.vbs.txt (3.2 KB)
- Open Preferences / Toolbars / Scripts.
- Drag the file into the list of scripts.
- Click OK (or continue to Configuration, below).
Configuration:
Go to Prefences / Toolbars / Scripts, locate the Load All Thumbnails script, and click its underlined name to open the add-in's configuration window.
When done, remember that changes are not saved until you click OK or Apply back in the main Preferences dialog.
Double-click any option to edit it.
The options are as follows:
-
Folders:
A list of one or more folders which you want the script to affect. Double-click to edit, and add one folder per line. Do not put quotes around any paths.
Folders not in the list behave normally, according to the main Load all thumbnails in a folder automatically Preferences option.
Folders in the list will have all of their thumbnails loaded automatically, regardless of the Preferences option.
-
PreCache:
If PreCache is set to False, the add-in does not do anything until you are in Thumbnails or Tiles modes. (This avoids spending time loading thumbnails if you aren't going to view them.)
If PreCache is set to True, thumbnail loading begins immediately after you change to one of the listed folders, even if you are not displaying thumbnails yet. (This means the thumbnails can be ready even earlier, if you know you are likely to switch them on.)
History:
- v1.0 (02/Oct/2019) - Initial version.
The script itself:
If you just want to use the script, use the LoadAllThumbnails.vbs.txt download above.
The script code is reproduced here so people can find scripting techniques by browsing the forum:
Option Explicit
Function OnInit(initData)
initData.name = "Load All Thumbnails"
initData.version = "1.0"
initData.desc = "Load all thumbnails only in specific folders, without it being enabled globally"
initData.copyright = "(c) 2019 Leo Davidson"
initData.url = "https://resource.dopus.com/t/auto-load-thumbnails-only-in-specific-folders/33666"
initData.default_enable = true
initData.min_version = "12.17"
Dim vecDefFolders
Set vecDefFolders = DOpus.Create.Vector
initData.config.Folders = vecDefFolders
initData.config.PreCache = False
initData.config_desc = DOpus.Create.Map( _
"Folders", "Folders which trigger the command. (One per line.)", _
"PreCache", "If True, thumbnails generate on folder change even if not in Thumbnails or Tiles modes.")
End Function
Function OnAfterFolderChange(afterFolderChangeData)
If (Not afterFolderChangeData.result) Then
Exit Function ' Folder didn't change.
End If
' Un-comment to make qualifiers (e.g. Alt, Shift, Ctrl) temporarily disable the script.
' If (afterFolderChangeData.qualifiers <> "none") Then
' Exit Function
' End If
If (Not Script.config.PreCache) Then
If (Not AreThumbnailsDisplayed(afterFolderChangeData.tab)) Then
Exit Function ' Not displaying thumbnails, so do nothing yet.
End If
End If
If (Not IsPathInVector(DOpus.FSUtil, afterFolderChangeData.tab.Path, Script.config.Folders)) Then
Exit Function
End If
LoadAllThumbs afterFolderChangeData.tab
End Function
Function OnDisplayModeChange(displayModeChangeData)
If (Script.config.PreCache) Then
Exit Function ' We will have loaded them already when we changed folders.
End If
If (Not AreThumbnailsDisplayed(displayModeChangeData.tab)) Then
Exit Function ' Not displaying thumbnails, so do nothing.
End If
If (Not IsPathInVector(DOpus.FSUtil, displayModeChangeData.tab.Path, Script.config.Folders)) Then
Exit Function
End If
LoadAllThumbs displayModeChangeData.tab
End Function
Function AreThumbnailsDisplayed(tab)
AreThumbnailsDisplayed = False
Dim format, viewMode
Set format = tab.format
viewMode = format.view
' Check for Thumbnails or Tiles mode.
If (viewMode = "thumbnails" OR viewMode = "tile") Then
AreThumbnailsDisplayed = True
Exit Function
End If
' Also see if we're in Details or Power mode with the
' Thumbnail column turned on. (Note that we don't react to
' this being turned on by itself; we only notice if it is
' on after reading a folder or changing display modes.)
If (viewMode = "details" OR viewMode = "power") Then
Dim col
For Each col in format.columns
If (col.name = "thumbnail") Then
AreThumbnailsDisplayed = True
Exit Function
End If
Next
End If
End Function
Function LoadAllThumbs(tab)
Dim cmd
Set cmd = DOpus.Create.Command
cmd.SetSourceTab tab
cmd.RunCommand "Show LOADALLTHUMBS"
End Function
Function IsPathInVector(fsu, path, vecFolders)
IsPathInVector = False
' Resolve aliases, libraries, etc. to their real/absolute paths.
path = fsu.Resolve(path)
Dim testPath
For Each testPath in vecFolders
If (fsu.ComparePath(path, fsu.Resolve(testPath))) Then
IsPathInVector = True
Exit Function
End If
Next
End Function