Image viewer: How to keep last displayed image file selected when exiting full screen view?

Hello bonjour!

How does one keep last displayed image file selected when exiting full screen view?

Say you have a folder with lots of images and double click the first top image to view it in full screen mode, then use the mouse wheel or arrow keys to view the subsequent images until you are done viewing. Currently when hitting the ESC key the image that was double clicked to go full screen stays selected. I'd rather like to have the last viewed image file selected after exiting full screen mode so I know at what position in the folder I stopped viewing and don't jump (all the way) back to the first image in the folder.

Is there a way to change this behaviour some way?

Thank you in advance!

Either:

  • Click the folder icon on the viewer toolbar, which will select that file in a file display (opening the folder automatically if it isn't already open somewhere).

Or:

  • Turn on Link to Lister in the viewer (or open it linked to begin with; right-clicking the viewer pane button on the default Lister toolbars will do that), so the file display and viewer selections are tied together.

    (Preferences / Viewer / Standalone Viewer / Link both ways (file display selection tracks Lister-linked viewer) should also be turned on, if not already.)

Thank you for your reply @Leo.

I got the solutions you provided to work (Preferences / Viewer / Standalone Viewer / Link both ways (file display selection tracks Lister-linked viewer) was turned on already. I got a bit confused as to why these didn't also work when left double-clicking image thumbnails to view them full screen (as set in my Preferences / Viewer);

 

 

...it took me a while to figure out from this post that I also had to modify the 'Images' File Type Group / Commands / Events for the Left double-click event;

 

 

Can the Right click context menu item 'View in Directory Opus' also be adjusted so that the viewer opens linked when clicked for overall consistency?
 

Easiest way, without having to edit all the different things, is to do it via a script.

Download this and drop it on the Settings > Scripts dialog (or /scripts folder alias).

Code for reference:

function OnInit(initData)
{
	initData.name = "Auto Link Viewers";
	initData.version = "1.0";
	initData.copyright = "(c) 2026 Leo Davidson";
	initData.url = "https://resource.dopus.com/t/image-viewer-how-to-keep-last-displayed-image-file-selected-when-exiting-full-screen-view/60432/4";
	initData.desc = "Turn on lister-linking for all viewers that open";
	initData.default_enable = true;
	initData.min_version = "13.0";
}

function OnViewerEvent(viewerEventData)
{
	if (viewerEventData.event == "create"
	||	viewerEventData.event == "destroy"
	||	viewerEventData.event == "load")
	{
		var strViewer = viewerEventData.viewer + "";
		var pendingViewers;

		if (DOpus.Vars.Exists("LinkPendingViewers"))
		{
			pendingViewers = DOpus.Vars.Get("LinkPendingViewers");
		}
		else
		{
			pendingViewers = DOpus.Create.StringSet();
			DOpus.Vars.Set("LinkPendingViewers", pendingViewers);
		}
	
		if (viewerEventData.event == "create")
		{
			pendingViewers.insert(strViewer);
		}
		else if (viewerEventData.event == "destroy")
		{
			pendingViewers.erase(strViewer);
		}
		else if (viewerEventData.event == "load" && pendingViewers.exists(strViewer))
		{
			pendingViewers.erase(strViewer);
			viewerEventData.viewer.Command("listerlink,on");
		}
	}
}

Most of the complexity is in ensuring it only turns on linking for the first image, so you can still turn it off. If you never want to turn it off, the script could be simplified a lot:

function OnInit(initData)
{
	initData.name = "Auto Link Viewers";
	initData.version = "1.0";
	initData.copyright = "(c) 2026 Leo Davidson";
	initData.url = "https://resource.dopus.com/t/image-viewer-how-to-keep-last-displayed-image-file-selected-when-exiting-full-screen-view/60432/4";
	initData.desc = "Turn on lister-linking for all viewers that open";
	initData.default_enable = true;
	initData.min_version = "13.0";
}

function OnViewerEvent(viewerEventData)
{
	if (viewerEventData.event == "load")
	{
		viewerEventData.viewer.Command("listerlink,on");
	}
}

Wow Leo, thank you very much for this!! If this isn't help and service on request, I don't know what is :smiley: :crown: