This commit is contained in:
BoHung Chiu 2022-09-12 22:41:44 +08:00
parent c952afb56d
commit 56a4f3a3f8
2 changed files with 187 additions and 179 deletions

View File

@ -91,9 +91,17 @@ class AdImage
def embed_url
uri = URI.parse(self.youtube) rescue nil
if !uri.nil? && uri.host == "www.youtube.com"
params = CGI.parse(uri.query)
v = params['v'].first
if uri.path.start_with?('/embed/')
return self.youtube.sub(/http(s|):\/\//,'//')
else
params = CGI.parse(uri.query.to_s)
v = params.blank? ? nil : params['v'].first
if v.blank?
return ""
else
return "//www.youtube.com/embed/#{v}"
end
end
else
return ""
end

View File

@ -171,7 +171,7 @@
$("*[data-yt-binded=0]").each(function(){
init_yt_banner(this);
})
if (typeof onYouTubeIframeAPIReady !== 'function'){
if (typeof onYouTubeIframeAPIReady !== 'function'){
$(document).ready(function() {
$(document).on('touchstart click mousedown',".jarallax-video-audio",function(){
$(this).trigger('click');
@ -357,7 +357,7 @@ if (typeof onYouTubeIframeAPIReady !== 'function'){
}
{{extra_state_chnage_script}}
}
}
}
$(document).ready(function(){
window.onYouTubePlayerAPIReady = function() {
onYouTubeIframeAPIReady.apply(this,arguments);