lib/onebox/engine/soundcloud_onebox.rb in onebox-1.5.28 vs lib/onebox/engine/soundcloud_onebox.rb in onebox-1.5.29
- old
+ new
@@ -6,20 +6,29 @@
matches_regexp(/^https?:\/\/.*soundcloud\.com/)
always_https
def to_html
- get_oembed_data[:html].gsub!('height="400"', 'height="250"')
+ oembed_data = get_oembed_data[:html]
+ oembed_data.gsub!('visual=true', 'visual=false') || oembed_data
end
def placeholder_html
"<img src='#{get_oembed_data[:thumbnail_url]}'>"
end
private
+ def set?
+ url =~ /\/sets\//
+ end
+
def get_oembed_data
- Onebox::Helpers.symbolize_keys(::MultiJson.load(Onebox::Helpers.fetch_response("https://soundcloud.com/oembed.json?url=#{url}").body))
+ if set?
+ Onebox::Helpers.symbolize_keys(::MultiJson.load(Onebox::Helpers.fetch_response("https://soundcloud.com/oembed.json?url=#{url}").body))
+ else
+ Onebox::Helpers.symbolize_keys(::MultiJson.load(Onebox::Helpers.fetch_response("https://soundcloud.com/oembed.json?url=#{url}&maxheight=166").body))
+ end
end
end
end
end