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:
jbrw
2020-08-07 12:08:59 -04:00
committed by GitHub
parent abebc4e05e
commit 3593e582a3
13 changed files with 108 additions and 71 deletions

View File

@ -269,7 +269,7 @@ class Post < ActiveRecord::Base
%w{raw_mentions
linked_hosts
image_count
embedded_media_count
attachment_count
link_count
raw_links

View File

@ -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