diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-02-12 10:42:18 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-02-12 10:42:18 +0100 |
commit | 20844c828a4ec8c42773fe61ec9127567044a24a (patch) | |
tree | a8a3ffff1f258717036e7fa9075b956fb4dddcd9 | |
parent | 0841d29c4c05f877477cc8759ccebb2ff598138e (diff) | |
download | nextcloud-server-20844c828a4ec8c42773fe61ec9127567044a24a.tar.gz nextcloud-server-20844c828a4ec8c42773fe61ec9127567044a24a.zip |
Show open graph preview in WhatsApp
Whatsapp is picky about the size of the open graph images.
So we do some special handling.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareController.php | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index eff6cf65142..b5b2979ec6b 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -385,7 +385,18 @@ class ShareController extends Controller { // We just have direct previews for image files if ($share->getNode()->getMimePart() === 'image') { $shareTmpl['previewURL'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.publicpreview.directLink', ['token' => $token]); + $ogPreview = $shareTmpl['previewURL']; + + //Whatapp is kind of picky about their size requirements + if ($this->request->isUserAgent(['/^WhatsApp/'])) { + $ogPreview = $this->urlGenerator->linkToRouteAbsolute('files_sharing.PublicPreview.getPreview', [ + 't' => $token, + 'x' => 256, + 'y' => 256, + 'a' => true, + ]); + } } } else { $shareTmpl['previewImage'] = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'favicon-fb.png')); |