mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-22 14:15:22 +00:00
parent
3cecf3e5b9
commit
9b89c62d43
|
@ -136,14 +136,15 @@ class FetchLinkCardService < BaseService
|
||||||
detector = CharlockHolmes::EncodingDetector.new
|
detector = CharlockHolmes::EncodingDetector.new
|
||||||
detector.strip_tags = true
|
detector.strip_tags = true
|
||||||
|
|
||||||
guess = detector.detect(@html, @html_charset)
|
guess = detector.detect(@html, @html_charset)
|
||||||
page = Nokogiri::HTML(@html, nil, guess&.fetch(:encoding, nil))
|
page = Nokogiri::HTML(@html, nil, guess&.fetch(:encoding, nil))
|
||||||
|
player_url = meta_property(page, 'twitter:player')
|
||||||
|
|
||||||
if meta_property(page, 'twitter:player')
|
if player_url && !bad_url?(Addressable::URI.parse(player_url))
|
||||||
@card.type = :video
|
@card.type = :video
|
||||||
@card.width = meta_property(page, 'twitter:player:width') || 0
|
@card.width = meta_property(page, 'twitter:player:width') || 0
|
||||||
@card.height = meta_property(page, 'twitter:player:height') || 0
|
@card.height = meta_property(page, 'twitter:player:height') || 0
|
||||||
@card.html = content_tag(:iframe, nil, src: meta_property(page, 'twitter:player'),
|
@card.html = content_tag(:iframe, nil, src: player_url,
|
||||||
width: @card.width,
|
width: @card.width,
|
||||||
height: @card.height,
|
height: @card.height,
|
||||||
allowtransparency: 'true',
|
allowtransparency: 'true',
|
||||||
|
|
Loading…
Reference in a new issue