mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 14:07:30 +08:00
FIX - limit number of embedded media items in a post (#10391)
* FIX - limit number of embedded media items in a post * Add renamed settings to DeprecatedSettings
This commit is contained in:
@ -269,7 +269,7 @@ class Post < ActiveRecord::Base
|
||||
|
||||
%w{raw_mentions
|
||||
linked_hosts
|
||||
image_count
|
||||
embedded_media_count
|
||||
attachment_count
|
||||
link_count
|
||||
raw_links
|
||||
|
@ -47,10 +47,11 @@ class PostAnalyzer
|
||||
end
|
||||
|
||||
# How many images are present in the post
|
||||
def image_count
|
||||
def embedded_media_count
|
||||
return 0 unless @raw.present?
|
||||
|
||||
cooked_stripped.css("img").reject do |t|
|
||||
# TODO - do we need to look for tags other than img, video and audio?
|
||||
cooked_stripped.css("img", "video", "audio").reject do |t|
|
||||
if dom_class = t["class"]
|
||||
(Post.allowed_image_classes & dom_class.split).count > 0
|
||||
end
|
||||
|
Reference in New Issue
Block a user