UX: allow youtube embed width and height to be passed as param

This commit is contained in:
Arpit Jalan 2015-05-26 18:03:50 +05:30
parent a797f7c664
commit 7608409fdb
1 changed files with 4 additions and 1 deletions

View File

@ -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