Question

I have a site where I want to be able to upload and embed videos. I use Rails 4 and the ruby-oembed gem.

I want to be able to edit some of the parameters for the embed code. In one of my models I have the following code:

before_validation { embed_code_from_url self.embed_url}

private 

  def embed_code_from_url(url)
    url = url + "?width=100px"
    resource = OEmbed::Providers::Vimeo.get(url)    
    self.embed_code = resource.html       
  end

OEmbedseems to ignore the extra parameters. Is it possible to have custom parameters with OEmbed, and how could I do that in a rails app?

Was it helpful?

Solution

The signature for the #get is get(url, query = {})

So, try:

resource = OEmbed::Providers::Vimeo.get(url, width: "100px")    
self.embed_code = resource.html  
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top