Question: Display Grid view when sharing a folder of photos via url?

While not a final solution, if we have access to the code, we can change the core/js/public/publicpage.js so it changes the layout if it detects a pattern on the URL.

For instance:

on the function window.addEventListener('DOMContentLoaded', function () { we can add:

if ( window.location.hash === "#view-grid" ) {
	$('#view-toggle').removeClass('icon-toggle-pictures').addClass('icon-toggle-filelist');
	$('#filestable').addClass('view-grid');
}

This will change the layout to the grid layout if we add #view-grid to our URL.
If we do not use the if condition and add directly the code inside, then it should always default to the grid layout.

eg:
Original URL: https://my.domain/s/tNFJb66Eb4dHzEH
Final URL: https://my.domain/s/tNFJb66Eb4dHzEH#view-grid

If attempting this, please make a backup of the file, since the patch can change at any time depending on the version of nextcloud.

Take a note that if the visitor wants to change the layout back to the list, the visitor will need to double click since all we did was change the style for the page so it rendered the grid layout. As long as the code that runs inside is concerned it is in the list layout.

4 Likes