简体   繁体   中英

ruby-oembed, Vimeo custom parameters?

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

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

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

So, try:

resource = OEmbed::Providers::Vimeo.get(url, width: "100px")    
self.embed_code = resource.html  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM