GP SoftwareTwitter
Opus FAQsManualCommandsObjects

How to set a folder view in thumbnails with fixed thumbnails size?

I Want To set a folder view in thumbnails with fixed thumbnails size.
example: E:\Digital Music Archive is my target folder. I want to set its view in thumbnails with the size of the fixed thumbnails in 384px. I create a path format for that.


In This format, I can set display>> view as>> Thumbnails, But I can't find any way to set the size of the thumbnails in 384px. Is there any way to do this.

now I create a toolbar button to set the thumbnails size in 384px Show THUMBNAILSIZE 384

I also try to modify a script found in this forum which set the view in flat mode

Option Explicit

Function OnInit(initData)
	initData.name = "Flat-View Auto"
	initData.version = "1.0"
	initData.desc = "Automatically turn on Flat View when entering configured folders"
	initData.copyright = "(c) 2015 Leo Davidson"
	initData.default_enable = true

	Dim vecDefFolders
	Set vecDefFolders = DOpus.Create.Vector
	' Default folders / example config.
	vecDefFolders.push_back("/desktop")
	vecDefFolders.push_back("C:\Program Files\GPSoftware\Directory Opus")

	initData.config.FlatViewCommand = "Set FLATVIEW=On,Grouped"
	initData.config.FlatViewFolders = vecDefFolders

	initData.config_desc = DOpus.Create.Map( _
		"FlatViewCommand", "Command to run when triggered.", _
		"FlatViewFolders", "Folders which trigger the command.")
End Function

' Helper 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

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 IsPathInVector(DOpus.FSUtil, afterFolderChangeData.tab.Path, Script.config.FlatViewFolders)) Then
		Exit Function
	End If
	
	Dim cmd
	Set cmd = DOpus.Create.Command
	cmd.SetSourceTab afterFolderChangeData.tab
	cmd.RunCommand Script.config.FlatViewCommand

End Function

The modified version is

Option Explicit

Function OnInit(initData)
	initData.name = "Thumbnails-view"
	initData.version = "1.0"
	initData.desc = "Automatically turn on Thumbnails View when entering configured folders"
	initData.copyright = "(c) 2015 Leo Davidson"
	initData.default_enable = true

	Dim vecDefFolders
	Set vecDefFolders = DOpus.Create.Vector
	' Default folders / example config.
	vecDefFolders.push_back("/desktop")
	vecDefFolders.push_back("C:\Program Files\GPSoftware\Directory Opus")

	initData.config.ThumbnailsViewCommand = "Set VIEW=Thumbnails,384px"
	initData.config.ThumbnailsViewFolders = vecDefFolders

	initData.config_desc = DOpus.Create.Map( _
		"ThumbnailsViewCommand", "Command to run when triggered.", _
		"ThumbnailsViewFolders", "Folders which trigger the command.")
End Function

' Helper 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

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 IsPathInVector(DOpus.FSUtil, afterFolderChangeData.tab.Path, Script.config.ThumbnailsViewFolders)) Then
		Exit Function
	End If
	
	Dim cmd
	Set cmd = DOpus.Create.Command
	cmd.SetSourceTab afterFolderChangeData.tab
	cmd.RunCommand Script.config.ThumbnailsViewCommand

End Function

Is there any way to set fixed thumbnails size in 384px for a folder?

The script method should work if you want.

It sounds like you already had the script method working in the past?

Leo thanks for replay, but as I was said there is problem Leo, the script also effect another location without the location i set in the script. Plz give me a solution.

"Hey Leo, I use this script, and it's work fine for me but there is a problem also.
D:\Scan is my target folder where I want to set thumbnail size 384x384. I configured the script with D:\Scan and Show THUMBNAILSIZE=source,384. when I open D:\Scan then it's display in thumbnail in 384 as I configured. But When I click the GO UP Button to go D:\ then it's also display in thumbnail in 384. what I don't want. for your kind information before I installed this script the location D:\ display in thumbnail mode in default thumbnail size what was natural. But after install the script the thumbnail size become 384x384 from default size when I come back from D:\Scan to D:\ Drive. how to solve this problem Leo?"

You'd need to change the script so it runs one command in folders which do match the path (it already does that) and also runs a different command in folders which don't match the path.

Isn't the maximum size for thumbnails 256?

It scales with DPI but you can also override that via Preferences / Miscellaneous / Advanced [Limits]: max_thumbnail_size.

1 Like

How to stop the script to "runs a different command in folders which don't match the path." Leo?

Here is an entirely different approach to this issue, which I have used for a long time now.

Say you have two sets of folders you need to display folder with different size thumbs.

First create a tab group of the folders you need

Next create a a toolbar to open those tab groups.

For instance if you have an Images tab group and a Graphics tab group.

On the toolbar create two buttons: Images and Graphics.

On the Images button add the code:

Go TABGROUPLOAD="Name of your tab group" TABCLOSEALL=yes
Show THUMBNAILSIZE 300
Set LISTERSIZE = 2800,1786
Set LISTERPOS = 100,10

On the Graphics button add the code:

Go TABGROUPLOAD "Name of Your Tab Group" TABCLOSEALL=yes
Show THUMBNAILSIZE 180
Set LISTERSIZE = 2800,1690
Set LISTERPOS = 100,10

Obviously the listersize is determined by your monitor, but you can set it up to display say three rows of thumbs and captions, which makes everything very neatly.

It may not be what you want, but it is another way of doing things and underlines the versatility of Opus.

Thanks auden for share your idea. Tab group can solve it. But I think the script is the best and smooth way to handle this issue. just need a little modify of the script. I hope Leo will help in this point.

And Finally My Dear Brother aussieboykie has Solve the problem. Thanks to him.

After Fixed Some bugs by Brother aussieboykie. This Is the Update version 1.0.1 of the script.eventOnFolderChange.js.txt (2.8 KB). All the credit goes to aussieboykie.

Actually, most of the credit belongs to @leo whose original Trigger Flat View (or any other command) in configured folders script I shamelessly plagiarised. :grinning: