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
sudo apt install libreoffice ffmpeg imagemagick ghostscript
Now edit config/config.php file of your nextcloud installation, add following code
'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).
chsh --shell /bin/bash www-data
Now change to www-data user
su - www-data
Now run
/usr/bin/php /var/www/nextcloud/occ preview:generate-all -vvv
Autogenerate Previews for new files
set a cronjob as user www-data
crontab -e -u www-data
*/5 * * * * /usr/bin/php /var/www/nextcloud/occ preview:pre-generate > /dev/null 2>&1
See Nextcloud
Leave a Reply