mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 19:41:18 +08:00
FIX: Disable lightboxing of animated images (#13099)
This commit is contained in:
@ -353,13 +353,13 @@ class CookedPostProcessor
|
||||
unless @disable_loading_image
|
||||
upload.create_thumbnail!(LOADING_SIZE, LOADING_SIZE, format: 'png', colors: LOADING_COLORS)
|
||||
end
|
||||
end
|
||||
|
||||
return if upload.animated?
|
||||
|
||||
if img.ancestors('.onebox, .onebox-body, .quote').blank? && !img.classes.include?("onebox")
|
||||
add_lightbox!(img, original_width, original_height, upload, cropped: crop)
|
||||
end
|
||||
|
||||
if upload.present?
|
||||
optimize_image!(img, upload, cropped: crop)
|
||||
end
|
||||
end
|
||||
@ -390,7 +390,7 @@ class CookedPostProcessor
|
||||
w, h = img["width"].to_i, img["height"].to_i
|
||||
|
||||
# note: optimize_urls cooks the src and data-small-upload further after this
|
||||
thumbnail = !upload.animated && upload.thumbnail(w, h)
|
||||
thumbnail = upload.thumbnail(w, h)
|
||||
if thumbnail && thumbnail.filesize.to_i < upload.filesize
|
||||
img["src"] = thumbnail.url
|
||||
|
||||
|
@ -973,7 +973,10 @@ describe CookedPostProcessor do
|
||||
expect(doc.css('img').first['srcset']).to_not eq(nil)
|
||||
end
|
||||
|
||||
it "does not optimize animated images but adds a class so animated images can be identified" do
|
||||
it "processes animated images correctly" do
|
||||
# skips optimization
|
||||
# skips lightboxing
|
||||
# adds "animated" class to element
|
||||
upload.update!(animated: true)
|
||||
post = Fabricate(:post, raw: "")
|
||||
|
||||
@ -981,7 +984,7 @@ describe CookedPostProcessor do
|
||||
cpp.post_process
|
||||
|
||||
doc = Nokogiri::HTML5::fragment(cpp.html)
|
||||
expect(doc.css('.lightbox-wrapper').size).to eq(1)
|
||||
expect(doc.css('.lightbox-wrapper').size).to eq(0)
|
||||
expect(doc.css('img').first['src']).to include(upload.url)
|
||||
expect(doc.css('img').first['srcset']).to eq(nil)
|
||||
expect(doc.css('img.animated').size).to eq(1)
|
||||
|
@ -241,7 +241,7 @@ describe SearchIndexer do
|
||||
post.rebake!
|
||||
post.reload
|
||||
|
||||
expect(post.cooked).to include(
|
||||
expect(post.cooked).not_to include(
|
||||
CookedPostProcessor::LIGHTBOX_WRAPPER_CSS_CLASS
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user