From ad7c31914f080cdcec98dfadfb6e4d19416260dc Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 12 Feb 2018 10:42:18 +0100 Subject: [PATCH] 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 --- apps/files_sharing/lib/Controller/ShareController.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index c51bc1a75d..3669d8fda4 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'));