Install Preview Generator in Nextcloud
To enable preview for files in nextcloud, you need to install “Preview Generator” from next cloud app store
https://apps.nextcloud.com/apps/previewgenerator
To install login to nextcloud as admin. From right drop down menu, click + Apps link.
Once on Apps page, you can use the search button on right side to search for “Preview Generator” and install it.
You need to install some additional software, on ubuntu/debian install it with
1 |
sudo apt install libreoffice ffmpeg imagemagick ghostscript |
Now edit config/config.php file of your nextcloud installation, add following code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
'enable_previews' => true, 'preview_libreoffice_path' => '/usr/bin/libreoffice', 'enabledPreviewProviders' => array ( 0 => 'OC\\Preview\\TXT', 1 => 'OC\\Preview\\MarkDown', 2 => 'OC\\Preview\\OpenDocument', 3 => 'OC\\Preview\\PDF', 4 => 'OC\\Preview\\MSOffice2003', 5 => 'OC\\Preview\\MSOfficeDoc', 6 => 'OC\\Preview\\PDF', 7 => 'OC\\Preview\\Image', 8 => 'OC\\Preview\\Photoshop', 9 => 'OC\\Preview\\TIFF', 10 => 'OC\\Preview\\SVG', 11 => 'OC\\Preview\\Font', 12 => 'OC\\Preview\\MP3', 13 => 'OC\\Preview\\Movie', 14 => 'OC\\Preview\\MKV', 15 => 'OC\\Preview\\MP4', 16 => 'OC\\Preview\\AVI', ), |
Generate Preview for existing files
Let’s generate thumbnail for existing files, for this, I enabled shell access for www-data so preview files have proper file ownership (not owned by root).
1 |
chsh --shell /bin/bash www-data |
Now change to www-data user
1 |
su - www-data |
Now run
1 |
/usr/bin/php /var/www/nextcloud/occ preview:generate-all -vvv |
Autogenerate Previews for new files
set a cronjob as user www-data
1 |
crontab -e -u www-data |
1 |
*/5 * * * * /usr/bin/php /var/www/nextcloud/occ preview:pre-generate > /dev/null 2>&1 |
See Nextcloud