mirror of
https://github.com/discourse/discourse.git
synced 2025-02-12 02:25:33 +08:00
FIX: Strip lightbox metadata from embedding comments
This commit is contained in:
parent
6d4c07385f
commit
be17b3e04f
|
@ -16,12 +16,14 @@ module EmbedHelper
|
||||||
|
|
||||||
def get_html(cooked)
|
def get_html(cooked)
|
||||||
fragment = Nokogiri::HTML.fragment(cooked)
|
fragment = Nokogiri::HTML.fragment(cooked)
|
||||||
|
|
||||||
# convert lazyYT div to link
|
# convert lazyYT div to link
|
||||||
fragment.css('div.lazyYT').each do |yt_div|
|
fragment.css('div.lazyYT').each do |yt_div|
|
||||||
youtube_id = yt_div["data-youtube-id"]
|
youtube_id = yt_div["data-youtube-id"]
|
||||||
youtube_link = "https://www.youtube.com/watch?v=#{youtube_id}"
|
youtube_link = "https://www.youtube.com/watch?v=#{youtube_id}"
|
||||||
yt_div.replace "<p><a href='#{youtube_link}'>#{youtube_link}</a></p>"
|
yt_div.replace "<p><a href='#{youtube_link}'>#{youtube_link}</a></p>"
|
||||||
end
|
end
|
||||||
|
|
||||||
# convert Vimeo iframe to link
|
# convert Vimeo iframe to link
|
||||||
fragment.css('iframe').each do |iframe|
|
fragment.css('iframe').each do |iframe|
|
||||||
if iframe['src'] =~ /player.vimeo.com/
|
if iframe['src'] =~ /player.vimeo.com/
|
||||||
|
@ -29,6 +31,10 @@ module EmbedHelper
|
||||||
iframe.replace "<p><a href='https://vimeo.com/#{vimeo_id}'>https://vimeo.com/#{vimeo_id}</a></p>"
|
iframe.replace "<p><a href='https://vimeo.com/#{vimeo_id}'>https://vimeo.com/#{vimeo_id}</a></p>"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Strip lightbox metadata
|
||||||
|
fragment.css('.lightbox-wrapper .meta').remove
|
||||||
|
|
||||||
raw fragment
|
raw fragment
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user