R biz
R biz

Reputation: 11

I'm getting blur thumbnail from Vimeo API

The problem that I am having is that the images are being pulled through to my website in different sizes, which means they are sometimes blurred.

For Eg. Here are two videos on Vimeo which exactly the same thumbnail image:

I'm attaching screenshot of the 2 videos embedded on my site. Video 315599618 (Test123 on our site) has a well defined image, and 335868910 (Swiped on our site) has a blurred image.

Test123 imageblurScreenshot in my website

This two functions I am using to get the image from vimeo api

public static function getVimeoData1($vimeo_url)
   {
       if( !$vimeo_url ) return false;
       @$data = json_decode( file_get_contents( 'http://vimeo.com/api/oembed.json?url=' . $vimeo_url ) );
       if( !$data ) return false;
       //return $data->thumbnail_url;
       return $data;
   }

   public static function getVimeoData2($vimeo_id)
   {
       if( !$vimeo_id ) return false;
       @$data = unserialize(file_get_contents("http://vimeo.com/api/v2/video/$vimeo_id.php"));
       if( !$data ) return false;
       //return $data[0];
       return $data;
   }

When I open those images separately, it is clear that for Swiped it is pulling through a smaller version of the thumbnail, which is why it is blurred when enlarged (see Test 123 and Swiped images attached). But there is no obvious reason why it would pull through a smaller version of the thumbnail as we are using the same code to pull through the images in both cases.

The site is built in PHP(Laravel) and the embed the Vimeo videos are using the following format - https://player.vimeo.com/video/335868910. If it helps I have included the code that is used to display the images as a footer in this email.

Please, can anyone help me to understand why this is happening and what we can do about it?

Upvotes: 1

Views: 1389

Answers (1)

Tommy Penner
Tommy Penner

Reputation: 3018

If you're using oEmbed to get a video's thumbnail, you should specify the media dimensions you want returned. Without specifying dimensions, you'll get a default size back, or some other unknown size.

Your oEmbed request should look like this:

https://vimeo.com/api/oembed.json?url=https://vimeo.com/335868910&width=1920&height=1080

The full list of oEmbed argumens is found here: https://developer.vimeo.com/api/oembed/videos

Upvotes: 1

Related Questions