Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vimeo hidden video poster 404 #187

Open
rjdusk opened this issue Feb 20, 2025 · 2 comments
Open

Vimeo hidden video poster 404 #187

rjdusk opened this issue Feb 20, 2025 · 2 comments

Comments

@rjdusk
Copy link

rjdusk commented Feb 20, 2025

Hi gang,
I've been really enjoying implementing this embed component throughout my website, but I've run into a bit of a snag. We have some videos on Vimeo that are "Hide from Vimeo but embeddable anywhere" and this setting appears to prevent the video poster from loading.

In my terminal I get this error:

[error]  astro-embed
Failed to fetch https://vimeo.com/api/v2/video/950746665.json
Error 404: Not Found

When trying to load one of these videos. I can however still press play and the video will load and play just fine. Any ideas on how I can fix this?
Thanks!

@delucis
Copy link
Owner

delucis commented Feb 20, 2025

Hey @rjdusk! I guess Vimeo blocks us from loading the the poster URL from their API if the video is hidden. I don’t know if there’s a fix on our end but a workaround would be to provide an explicit poster attribute on the video if you can grab the URL manually?

@rjdusk
Copy link
Author

rjdusk commented Feb 20, 2025

Ah ok that's a bummer @delucis - at any rate I'll just grab it via the oembed response:

let posterUrl = "/assets/global/featured-img.png";
try {
  const oembedResponse = await fetch(
    `https://vimeo.com/api/oembed.json?url=https%3A//vimeo.com/${videoId}`,
  );
  const oembedData = await oembedResponse.json();
  posterUrl = oembedData.thumbnail_url.replace(/-d_\d+x\d+/, "-d_960x540");
} catch (error) {
  console.error("Failed to fetch Vimeo thumbnail:", error);
}

then explicitly provide the poster URL to the Vimeo component. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants