This commit is contained in:
BoHung Chiu 2021-10-25 11:03:51 +08:00
parent 64e26d9e2e
commit 04da5dfc7e
1 changed files with 7 additions and 3 deletions

View File

@ -73,9 +73,13 @@ class AdImage
def youtube_thumb def youtube_thumb
uri = URI.parse(self.youtube) rescue nil uri = URI.parse(self.youtube) rescue nil
if !uri.nil? && uri.host == "www.youtube.com" if !uri.nil? && uri.host == "www.youtube.com"
params = CGI.parse(uri.query) params = CGI.parse(uri.query) rescue {}
v = params['v'].first if params.has_key?('v')
return "http://img.youtube.com/vi/#{v}/0.jpg" v = params['v'].first
return "http://img.youtube.com/vi/#{v}/0.jpg"
else
return ""
end
else else
return "" return ""
end end