@@ -12,15 +12,17 @@ function validURL(str){
12
12
}
13
13
14
14
function saveMetaToResLocal ( upload , uploadServer , req , res ) {
15
- let metaThumbnail ;
15
+ let formattedUploadServer ;
16
16
17
17
// if the upload server is a relative path prepend the protocol and host to make it an absolute url
18
18
if ( ! validURL ( uploadServer ) ) {
19
- metaThumbnail = req . protocol + '://' + req . get ( 'host' ) + uploadServer ;
19
+ formattedUploadServer = req . protocol + '://' + req . get ( 'host' ) + uploadServer ;
20
20
} else {
21
- metaThumbnail = uploadServer ;
21
+ formattedUploadServer = uploadServer ;
22
22
}
23
23
24
+ const baseUrl = req . protocol + '://' + req . get ( 'host' ) ;
25
+
24
26
/** SET META TAGS **/
25
27
res . locals . meta . title = `${ upload . title } ` ;
26
28
@@ -29,25 +31,23 @@ function saveMetaToResLocal(upload, uploadServer, req, res){
29
31
if ( upload . fileType == 'video' ) {
30
32
// set proper thumbnail url
31
33
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 } ` ;
33
35
} 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 } ` ;
35
37
} 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 } ` ;
37
39
}
38
40
39
- res . locals . meta . video = `${ metaThumbnail } /${ upload . uploader . channelUrl } /${ upload . uniqueTag } .mp4` ;
41
+ res . locals . meta . video = `${ formattedUploadServer } /${ upload . uploader . channelUrl } /${ upload . uniqueTag } .mp4` ;
40
42
}
41
43
42
- // TODO: fix this to use updated paths
43
44
if ( upload . fileType == 'audio' ) {
44
- res . locals . meta . image = upload . customThumbnailUrl || upload . thumbnailUrl ;
45
+ res . locals . meta . image = ` ${ baseUrl } /images/audio.svg`
45
46
}
46
47
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
+ }
51
51
52
52
}
53
53
0 commit comments