Skip to content

Commit

Permalink
Add image type to api
Browse files Browse the repository at this point in the history
  • Loading branch information
luwes committed Dec 19, 2019
1 parent fadce0a commit 66be61d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
3 changes: 2 additions & 1 deletion api/thumb.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type Video struct {
func Handler(w http.ResponseWriter, r *http.Request) {
rq := r.URL.Query()
videoid := rq.Get("videoid")
imageType := rq.Get("type")
mw := rq.Get("mw")
mh := rq.Get("mh")
quality := rq.Get("q")
Expand Down Expand Up @@ -107,7 +108,7 @@ func Handler(w http.ResponseWriter, r *http.Request) {

imageId := path.Base(video.Pictures.URI)

imageUrl, err := url.Parse(fmt.Sprintf("https://i.vimeocdn.com/video/%s.jpg", imageId))
imageUrl, err := url.Parse(fmt.Sprintf("https://i.vimeocdn.com/video/%s.%s", imageId, imageType))
if err != nil {
log.Fatal(err)
}
Expand Down
11 changes: 5 additions & 6 deletions now.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
"VIMEO_TOKEN": "@vimeo-token"
},
"rewrites": [
{ "source": "/thumb/:id", "destination": "/api/thumb.go?videoid=:id" }
{
"source": "/thumb/(\\d+).(\\w+)",
"destination": "/api/thumb.go?videoid=$1&type=$2"
}
],
"headers": [
{
"source": "/thumb/(.*)",
"source": "/thumb/(\\d+).(\\w+)",
"headers" : [
{
"key" : "Content-Type",
"value" : "application/json"
},
{
"key" : "Cache-Control",
"value" : "public, max-age=3600"
Expand Down
4 changes: 2 additions & 2 deletions src/lite-vimeo-embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class LiteVimeoEmbed extends HTMLElement {
*/

const api = 'https://lite-vimeo-embed.now.sh';
this._posterUrl = `${api}/thumb/${this.videoId}?mw=1600&mh=900&q=70`;
this._posterUrl = `${api}/thumb/${this.videoId}.jpg?mw=1600&mh=900&q=70`;

// Warm the connection for the poster image
LiteVimeoEmbed._addPrefetch('preload', this._posterUrl, 'image');
Expand All @@ -55,7 +55,7 @@ class LiteVimeoEmbed extends HTMLElement {
// Once the user clicks, add the real iframe and drop our play button
// TODO: In the future we could be like amp-youtube and silently swap in the iframe during idle time
// We'd want to only do this for in-viewport or near-viewport ones: https://github.com/ampproject/amphtml/pull/5003
this.addEventListener('click', e => this._addIframe());
this.addEventListener('click', () => this._addIframe());
}

// // TODO: Support the the user changing the [videoid] attribute
Expand Down

0 comments on commit 66be61d

Please sign in to comment.