Jump to content

Nextcloud Preview Generator


brent

Recommended Posts

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.

nextcloud-apps.png

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',
 ),

For more info on configuration, check nextcloud documenation.

Generate Preview for existing files

Lets 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: (Without www-data)

sudo -u www-data php /var/www/cloud.kc-linux.com/html/occ preview:generate-all -vvv

or (with switching to www-data user)

/usr/bin/php /var/www/nextcloud/occ preview:generate-all -vvv

nextcloud-preview-generate-all.png

 

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

 

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...