Embedly.oembed not adhering to the maxwidth parameter

166 Views Asked by At

I am trying to use Embedly to generate a thumbnail for a given url. I need the thumbnail to be smaller than a maximum size, so I call the api like so:

url = "http://embed.ly"
embedly_api = Embedly::API.new(key: ENV['EMBEDLY_KEY'])
obj = embedly_api.oembed(url: url, maxwidth: 50, type: 'photo').first

json_obj = JSON.pretty_generate(obj.marshal_dump)

or

http://api.embed.ly/1/oembed?key=[KEY_VALUE]&url=http://embed.ly&maxwidth=50&type=photo

In either case the result is:

{
  provider_url: "http://embed.ly",
  description: "Embedly delivers the ultra-fast,...",
  title: "Embedly makes your content more engaging and easier...",
  mean_alpha: 32.7480314961,
  thumbnail_width: 399,
  url: "http://embed.ly",
  thumbnail_url: "http://embed.ly/static/images/logos/logo_color.png?v=4b245",
  version: "1.0",
  provider_name: "Embedly",
  type: "link",
  thumbnail_height: 127
}

Notice that thumbnail_width is 399 (which is larger than what I passed in for the maxwidth parameter). Am I missing something obvious here?

1

There are 1 best solutions below

0
On BEST ANSWER

maxwidth only applies to the html, images can be of any width.

Embedly does allow you to set an image_width though. Try:

embedly_api.oembed(url: url, maxwidth: 50, type: 'photo', image_width: 50)

http://embed.ly/docs/api/display/integration