aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/client.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-11-11 15:44:08 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-11-16 20:29:26 +0100
commit41b5da1d8cb41f5c49f0e0a01a54106c9a5925dd (patch)
tree03033e34a2c0c924415e1639ee7d476007699e92 /server/controllers/client.js
parent55723d16fd0e323ce7175db8c4806c73d18b895d (diff)
downloadPeerTube-41b5da1d8cb41f5c49f0e0a01a54106c9a5925dd.tar.gz
PeerTube-41b5da1d8cb41f5c49f0e0a01a54106c9a5925dd.tar.zst
PeerTube-41b5da1d8cb41f5c49f0e0a01a54106c9a5925dd.zip
Server: use preview image for opengraph
Diffstat (limited to 'server/controllers/client.js')
-rw-r--r--server/controllers/client.js19
1 files changed, 15 insertions, 4 deletions
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
33// --------------------------------------------------------------------------- 33// ---------------------------------------------------------------------------
34 34
35function addOpenGraphTags (htmlStringPage, video) { 35function addOpenGraphTags (htmlStringPage, video) {
36 const thumbnailUrl = constants.CONFIG.WEBSERVER.URL + video.thumbnailPath
37 const videoUrl = constants.CONFIG.WEBSERVER.URL + '/videos/watch/' 36 const videoUrl = constants.CONFIG.WEBSERVER.URL + '/videos/watch/'
37 let baseUrlHttp
38
39 if (video.isOwned()) {
40 baseUrlHttp = constants.CONFIG.WEBSERVER.URL
41 } else {
42 baseUrlHttp = constants.REMOTE_SCHEME.HTTP + '://' + video.podUrl
43 }
44
45 // We fetch the remote preview (bigger than the thumbnail)
46 // This should not overhead the remote server since social websites put in a cache the OpenGraph tags
47 // We can't use the thumbnail because these social websites want bigger images (> 200x200 for Facebook for example)
48 const previewUrl = baseUrlHttp + constants.STATIC_PATHS.PREVIEWS + video.getPreviewName()
38 49
39 const metaTags = { 50 const metaTags = {
40 'og:type': 'video', 51 'og:type': 'video',
41 'og:title': video.name, 52 'og:title': video.name,
42 'og:image': thumbnailUrl, 53 'og:image': previewUrl,
43 'og:url': videoUrl, 54 'og:url': videoUrl,
44 'og:description': video.description, 55 'og:description': video.description,
45 56
46 'name': video.name, 57 'name': video.name,
47 'description': video.description, 58 'description': video.description,
48 'image': thumbnailUrl, 59 'image': previewUrl,
49 60
50 'twitter:card': 'summary_large_image', 61 'twitter:card': 'summary_large_image',
51 'twitter:site': '@Chocobozzz', 62 'twitter:site': '@Chocobozzz',
52 'twitter:title': video.name, 63 'twitter:title': video.name,
53 'twitter:description': video.description, 64 'twitter:description': video.description,
54 'twitter:image': thumbnailUrl 65 'twitter:image': previewUrl
55 } 66 }
56 67
57 let tagsString = '' 68 let tagsString = ''