From 41b5da1d8cb41f5c49f0e0a01a54106c9a5925dd Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 11 Nov 2016 15:44:08 +0100 Subject: Server: use preview image for opengraph --- server/controllers/client.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'server/controllers') diff --git a/server/controllers/client.js b/server/controllers/client.js index 68ffdbcd5..746c9b62b 100644 --- a/server/controllers/client.js +++ b/server/controllers/client.js @@ -33,25 +33,36 @@ module.exports = router // --------------------------------------------------------------------------- function addOpenGraphTags (htmlStringPage, video) { - const thumbnailUrl = constants.CONFIG.WEBSERVER.URL + video.thumbnailPath const videoUrl = constants.CONFIG.WEBSERVER.URL + '/videos/watch/' + let baseUrlHttp + + if (video.isOwned()) { + baseUrlHttp = constants.CONFIG.WEBSERVER.URL + } else { + baseUrlHttp = constants.REMOTE_SCHEME.HTTP + '://' + video.podUrl + } + + // We fetch the remote preview (bigger than the thumbnail) + // This should not overhead the remote server since social websites put in a cache the OpenGraph tags + // We can't use the thumbnail because these social websites want bigger images (> 200x200 for Facebook for example) + const previewUrl = baseUrlHttp + constants.STATIC_PATHS.PREVIEWS + video.getPreviewName() const metaTags = { 'og:type': 'video', 'og:title': video.name, - 'og:image': thumbnailUrl, + 'og:image': previewUrl, 'og:url': videoUrl, 'og:description': video.description, 'name': video.name, 'description': video.description, - 'image': thumbnailUrl, + 'image': previewUrl, 'twitter:card': 'summary_large_image', 'twitter:site': '@Chocobozzz', 'twitter:title': video.name, 'twitter:description': video.description, - 'twitter:image': thumbnailUrl + 'twitter:image': previewUrl } let tagsString = '' -- cgit v1.2.3