mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-13 06:35:08 +01:00
Translate incoming remote img tags by a link
This commit is contained in:
parent
2f83ffa1bd
commit
18b77224d3
@ -19,6 +19,17 @@ class Sanitize
|
|||||||
node['class'] = class_list.join(' ')
|
node['class'] = class_list.join(' ')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
IMG_TAG_TRANSFORMER = lambda do |env|
|
||||||
|
node = env[:node]
|
||||||
|
|
||||||
|
return unless env[:node_name] == 'img'
|
||||||
|
|
||||||
|
node.name = 'a'
|
||||||
|
|
||||||
|
node['href'] = node['src']
|
||||||
|
node.content = "[🖼 #{node['alt'] || node['href']}]"
|
||||||
|
end
|
||||||
|
|
||||||
MASTODON_STRICT ||= freeze_config(
|
MASTODON_STRICT ||= freeze_config(
|
||||||
elements: %w(p br span a abbr del pre blockquote code b strong u sub i em h1 h2 h3 h4 h5 ul ol li),
|
elements: %w(p br span a abbr del pre blockquote code b strong u sub i em h1 h2 h3 h4 h5 ul ol li),
|
||||||
|
|
||||||
@ -43,6 +54,7 @@ class Sanitize
|
|||||||
|
|
||||||
transformers: [
|
transformers: [
|
||||||
CLASS_WHITELIST_TRANSFORMER,
|
CLASS_WHITELIST_TRANSFORMER,
|
||||||
|
IMG_TAG_TRANSFORMER,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user