mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Check if video thumbnails site setting is enabled (#21306)
This commit is contained in:
parent
cd24656570
commit
e2fbf4865a
@ -1013,7 +1013,8 @@ class Post < ActiveRecord::Base
|
|||||||
upload ||= Upload.get_from_url(src)
|
upload ||= Upload.get_from_url(src)
|
||||||
|
|
||||||
# Link any video thumbnails
|
# Link any video thumbnails
|
||||||
if upload.present? && (FileHelper.supported_video.include? upload.extension&.downcase)
|
if SiteSetting.video_thumbnails_enabled && upload.present? &&
|
||||||
|
FileHelper.supported_video.include?(upload.extension&.downcase)
|
||||||
# Video thumbnails have the filename of the video file sha1 with a .png or .jpg extension.
|
# Video thumbnails have the filename of the video file sha1 with a .png or .jpg extension.
|
||||||
# This is because at time of upload in the composer we don't know the topic/post id yet
|
# This is because at time of upload in the composer we don't know the topic/post id yet
|
||||||
# and there is no thumbnail info added to the markdown to tie the thumbnail to the topic/post after
|
# and there is no thumbnail info added to the markdown to tie the thumbnail to the topic/post after
|
||||||
|
@ -1547,6 +1547,8 @@ RSpec.describe Post do
|
|||||||
|
|
||||||
let(:post) { Fabricate(:post, raw: raw_video) }
|
let(:post) { Fabricate(:post, raw: raw_video) }
|
||||||
|
|
||||||
|
before { SiteSetting.video_thumbnails_enabled = true }
|
||||||
|
|
||||||
it "has a topic thumbnail" do
|
it "has a topic thumbnail" do
|
||||||
# Thumbnails are tied to a specific video file by using the
|
# Thumbnails are tied to a specific video file by using the
|
||||||
# video's sha1 as the image filename
|
# video's sha1 as the image filename
|
||||||
@ -1577,6 +1579,16 @@ RSpec.describe Post do
|
|||||||
post.topic.reload
|
post.topic.reload
|
||||||
expect(post.topic.image_upload_id).to eq(image_upload_2.id)
|
expect(post.topic.image_upload_id).to eq(image_upload_2.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "does not create thumbnails when disabled" do
|
||||||
|
SiteSetting.video_thumbnails_enabled = false
|
||||||
|
image_upload.original_filename = "#{video_upload.sha1}.png"
|
||||||
|
image_upload.save!
|
||||||
|
post.link_post_uploads
|
||||||
|
|
||||||
|
post.topic.reload
|
||||||
|
expect(post.topic.topic_thumbnails.length).to eq(0)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "uploads" do
|
describe "uploads" do
|
||||||
|
Loading…
Reference in New Issue
Block a user