Skip to content

Commit 367fbb1

Browse files
committed
fix meta tags for audio and images
1 parent f9a5ba6 commit 367fbb1

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

lib/mediaPlayer/generateMetatags.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@ function validURL(str){
1212
}
1313

1414
function saveMetaToResLocal(upload, uploadServer, req, res){
15-
let metaThumbnail;
15+
let formattedUploadServer;
1616

1717
// if the upload server is a relative path prepend the protocol and host to make it an absolute url
1818
if(!validURL(uploadServer)){
19-
metaThumbnail = req.protocol + '://' + req.get('host') + uploadServer;
19+
formattedUploadServer = req.protocol + '://' + req.get('host') + uploadServer;
2020
} else {
21-
metaThumbnail = uploadServer;
21+
formattedUploadServer = uploadServer;
2222
}
2323

24+
const baseUrl = req.protocol + '://' + req.get('host');
25+
2426
/** SET META TAGS **/
2527
res.locals.meta.title = `${upload.title}`;
2628

@@ -29,25 +31,23 @@ function saveMetaToResLocal(upload, uploadServer, req, res){
2931
if(upload.fileType == 'video'){
3032
// set proper thumbnail url
3133
if(upload.thumbnail && upload.thumbnails.custom){
32-
res.locals.meta.image = `${metaThumbnail}/${upload.uploader.channelUrl}/${upload.thumbnails.custom}`;
34+
res.locals.meta.image = `${formattedUploadServer}/${upload.uploader.channelUrl}/${upload.thumbnails.custom}`;
3335
} else if(upload.thumbnails && upload.thumbnails.generated){
34-
res.locals.meta.image = `${metaThumbnail}/${upload.uploader.channelUrl}/${upload.thumbnails.generated}`;
36+
res.locals.meta.image = `${formattedUploadServer}/${upload.uploader.channelUrl}/${upload.thumbnails.generated}`;
3537
} else if(upload.thumbnails && upload.thumbnails.medium){
36-
res.locals.meta.image = `${metaThumbnail}/${upload.uploader.channelUrl}/${upload.thumbnails.medium}`;
38+
res.locals.meta.image = `${formattedUploadServer}/${upload.uploader.channelUrl}/${upload.thumbnails.medium}`;
3739
}
3840

39-
res.locals.meta.video = `${metaThumbnail}/${upload.uploader.channelUrl}/${upload.uniqueTag}.mp4`;
41+
res.locals.meta.video = `${formattedUploadServer}/${upload.uploader.channelUrl}/${upload.uniqueTag}.mp4`;
4042
}
4143

42-
// TODO: fix this to use updated paths
4344
if(upload.fileType == 'audio'){
44-
res.locals.meta.image = upload.customThumbnailUrl || upload.thumbnailUrl;
45+
res.locals.meta.image = `${baseUrl}/images/audio.svg`
4546
}
4647

47-
// TODO: implement this
48-
// if(upload.fileType == 'image'){
49-
// res.locals.meta.image = upload.customThumbnailUrl || upload.thumbnailUrl;
50-
// }
48+
if(upload.fileType == 'image'){
49+
res.locals.meta.image = `${formattedUploadServer}/${upload.uploader.channelUrl}/${upload.uniqueTag}${upload.fileExtension}`;
50+
}
5151

5252
}
5353

0 commit comments

Comments
 (0)