Skip to content
Snippets Groups Projects
Unverified Commit 6979b978 authored by Arnaud Levy's avatar Arnaud Levy Committed by GitHub
Browse files

Merge pull request #1388 from noesya/youtube-poster

Amélioration des posters
parents d587763b facd77d5
No related branches found
No related tags found
No related merge requests found
......@@ -7,8 +7,8 @@ class Video::Provider::Youtube < Video::Provider::Default
]
def identifier
video_url.include?('youtu.be') ? identifier_path
: identifier_param
short_url? ? param_from_short_url
: param_from_regular_url
end
def csp_domains
......@@ -32,13 +32,20 @@ class Video::Provider::Youtube < Video::Provider::Default
protected
def identifier_path
video_url.split('youtu.be/').last
def short_url?
video_url.include?('youtu.be')
end
def identifier_param
# youtube.com, www.youtube.com
def param_from_regular_url
uri = URI(video_url)
params = CGI::parse(uri.query)
params['v'].first
end
# youtu.be
def param_from_short_url
video_url.split('youtu.be/').last
.split('?').first
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment