HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Thumbnails for embedded private Vimeo videos
egroeg
New
hello there,
can't figure out why embedded private vimeo videos do not show up with a thumbnail (just the play icon)?
it works fine for public vimeo videos and youtube links. just not Vimeo ones with restricted access ("Hidden on Vimeo.com"; "Embedd on selected domains only")
Anybody with similar issues... and a solution? ;)
probably has to do with how the video request works in Vanilla? (guess the answer could be found on the Vimeo developer page... if one knows what they are talking about. Unfortunately I don't. 😔)
0
Comments
Okay, might have been to broad a question? But if you could point me in the right direction might be great already. :)
I found files dealing with embedding here:
/library/Vanilla/EmbeddedContent
no idea, how those factory or embed files work. but VimeoEmbedFactory.php seems to be processing the returned video meta data here:
but how do i fetch it? as it needs to be changed for privat links. as outlined in this link the request should look similar to this...
But I dont quite understand, how this curl-function would be used in Vanilla?
As far as I know, it's the server that fetches the video, not the user. So if the video is private, the server cannot access it although the users browser can.
Not sure if i understand. but the videos can be accessed. they are just missing the thumbnail. and vimeo says that the full info (including the thumbnails) has to be requested differently from regular public videos.
you are saying, that curl-command/function/... would be something that is happening on the server level? but vanilla has to request the video somewhere, right?
(sorry, but i don't have the slightest clue what is happening or what i am talking about. thanks for reading it anyway. ;) )
No problem, I'll explain it in another way:
Okay, that last point is a bit paranoid and I might be wrong there. But I just wanted to stress that if an implementation is done wrong, it opens security issues.
I am really sorry, but I still didn't get it. 🙈
But a new question came up...
tl;dr : How do I set the referrer URL in my Vanilla request for Video info?
.
If you have another peek at the Vimeo API info I posted earlier, at the very beginning, they are talking about a GET function.
To get an oEmbed response for a video on Vimeo, send a GET request to the following URL:
In VimeoEmbedFactory.php the video info is requested here:
e.g. with
https://vimeo.com/api/oembed.json?url=https://vimeo.com/31043422
I get all the correct info in the browser. But the same doesnt work for white-listed videos (I can only embed a video on certain URLs) as stated in the API description:
Step 1 in the previous section assumes that you're embedding a video with the public privacy setting. But for videos with the whitelist privacy setting — that is, videos with domain-level privacy — the results are a little different. The oEmbed request returns a simplified response containing no private metadata [...]
To get the complete response, including the private metadata, send the Referer header with the request, and set its value to the video's whitelisted domain. Here's what the request looks like in cURL (with the -e option, which gives you the Referer header) [...]
... and that's where they lost me. 😩
So I guess the real question should have been:
How do I set the referrer URL in my Vanilla request for Video info to Vimeo?
Okay, I was a little bit too hasty in the beginning. I saw "private videos" in the title and I had assumed that those videos are only accessible for users with access rights. Only now I have realized that you have explained it further as videos "Embedd on selected domains only".
Since you must send additional data when the video information is fetched, this code in the VimeoEmbedFactory is relevant:
This lines start the request where your referrer should be enclosed. I can think of three ways to ensure that.
1. (Worst but easiest) Change that code. The HttpClients get method allows specifying a custom header:
2. You can set default headers which will be send with every request the HttpClient starts. WHile this is slightly better than the above in terms of how you should extend Vanilla, it takes influence on each and every request the client initiates. Therefore I don't like that.
3. In theory it should be possible to replace which class is used as VimeoEmbedFactory. Instead of changing the original file, copying, changing the copy and let that copy be the default for Vimeo embeds would be the cleanest approach.
I was interested if 3. would be as "easy" as I thought and therefore I tested something. Please try the attached plugin. You need to edit line 58 of MyVimeoEmbedFactory.php
Not sure if this already works, but at least that file is used for Vimeo requests which makes it cleaner (than editing core files) if you want to test something
Please try the attached plugin.
That was it. works like a charm... again. Thanks a lot! 🙌
Would you suggest we just keep using that plugin on the live board?
For sure, that's the only clean approach, I'd say
By the way: thanks for the feedback! I wasn't that sure that it would really work ;-)
Hi @R_J,
sorry, but I have an additional issue:
The videos now have thumbnails ...although unfortunately, I have to edit and re-embed every single video to fetch the thumbnail, but it works! 🙌
What doesn't work is displaying the thumbnail correctly. Or rather getting a correct thumb. The thumbnails are always in landscape orientation and seem cropped (so a portrait video would be just the cropped center part in landscape orientation). Plus the image is somehow zoomed in. (See an example below.)
I couldn't see any width/ heigth "numbers" in your plugin, so I am assuming it is just requesting "the" thumbnail for the video. But do you think there is a chance of editing which thumbnail Vanilla fetches?
Thanks,
George
The thumbnail I get...
How it looks on the board...
What I was hoping to see...