Browse Source

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>
pull/8308/head
Roeland Jago Douma 9 years ago
parent
commit
20844c828a
No known key found for this signature in database GPG Key ID: F941078878347C0C
  1. 11
      apps/files_sharing/lib/Controller/ShareController.php

11
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'));

Loading…
Cancel
Save