FIX: get vimeo URL from data-original-href iframe attribute

This commit is contained in:
Arpit Jalan 2019-04-26 17:09:18 +05:30
parent bcca2b5d73
commit 66582ed956

View File

@ -375,8 +375,13 @@ module PrettyText
def self.convert_vimeo_iframes(doc)
doc.css("iframe[src*='player.vimeo.com']").each do |iframe|
vimeo_id = iframe['src'].split('/').last
iframe.replace "<p><a href='https://vimeo.com/#{vimeo_id}'>https://vimeo.com/#{vimeo_id}</a></p>"
if iframe["data-original-href"].present?
vimeo_url = iframe["data-original-href"]
else
vimeo_id = iframe['src'].split('/').last
vimeo_url = "https://vimeo.com/#{vimeo_id}"
end
iframe.replace "<p><a href='#{vimeo_url}'>#{vimeo_url}</a></p>"
end
end