Media browser remember last folder

Is there a way to remember the last folder which a user has selected in the media browser, so that when a user reopens the media browser that folder is selected? When the file-structure is comprehensive users have to do a lot of clicking to get to the right folder each time.

Tnx! Steffan

You can use Media Sources and assign those to specific users or even elements like TVs, so for example if you want an image TV pointing to your images folder, you can assign the created media source to that TV. Not sure if that fits your usecase though.

Thanks for the reply. I’m using media sources, but the problem is that each media source has dozens of subfolders in multiple levels. The media browser opens in the right source, but then the clicking starts… :slight_smile:

I’ve currently made it work by changing modx core code, which obviously isn’t the right approach. But I’m wondering if this is a good sollution and if might be a good feature request for modx?

I’ve added the following code to the init of getfiles.class.php and it seems to work pretty good. Whenever there is a folder selected in the media browser I store it in a session which then is used when the media browser is reopend.

		else $_SESSION["mediaBrowserDirectory"] = $this->getProperty("dir");

Any thoughts?

What happens when you open the media browser for a different media source, and the directory that you saved to the session is not valid in this media source? Does that create a problem?

It opens the ‘root’ folder of that media source, but it shows no files. So that might need a little tweaking.

I added a check to see whether or not the directory exists.

public function initialize() {
            'dir' => '',
		//show last used directory by default on init
			$ms = $this->modx->getObject('modMediaSource', $this->getProperty("source"))->get("properties");
		}else $_SESSION["mediaBrowserDirectory"] = $this->getProperty("dir");
        return true;