UX: allow youtube embed width and height to be passed as param
This commit is contained in:
parent
a797f7c664
commit
7608409fdb
|
@ -17,8 +17,11 @@ class Onebox::Engine::YoutubeOnebox
|
|||
|
||||
def to_html
|
||||
if video_id
|
||||
video_width = (params['width'] && params['width'].to_i <= 695) ? params['width'] : 480 # embed width
|
||||
video_height = (params['height'] && params['height'].to_i <= 500) ? params['height'] : 270 # embed height
|
||||
|
||||
# Put in the LazyYT div instead of the iframe
|
||||
"<div class=\"lazyYT\" data-youtube-id=\"#{video_id}\" data-youtube-title=\"#{video_title}\" data-width=\"480\" data-height=\"270\" data-parameters=\"#{embed_params}\"></div>"
|
||||
"<div class=\"lazyYT\" data-youtube-id=\"#{video_id}\" data-youtube-title=\"#{video_title}\" data-width=\"#{video_width}\" data-height=\"#{video_height}\" data-parameters=\"#{embed_params}\"></div>"
|
||||
else
|
||||
super
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue