How to have thumbnails in file dialogs in certain GTK applications

Note: The GTK file chooser got thumbnail support in version 4.10.

You can have large thumbnails in the file chooser in certain GTK 3 applications. Only a minority of applications supports this feature, but this minority includes Firefox and Thunderbird. The trick, surprisingly, is to force GTK applications to use KDE dialogs. You don’t need to use KDE itself, and the instructions assume you don’t.

The following instructions have been tested in Ubuntu 20.04. It should be possible to use them in other Linux distributions with small adjustments.

sudo apt install kio-extras xdg-desktop-portal-kde

sudo sed -i "s/\(UseIn=.*\)/\1;$XDG_CURRENT_DESKTOP/" /usr/share/xdg-desktop-portal/portals/kde.portal
echo GTK_USE_PORTAL=1 >> ~/.pam_environment

Done.