mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 14:12:10 +08:00
FIX: Quoted images should be lightboxed (#21332)
An older change about optimising images caused the selector that adds lightboxing not to apply on quoted images. This fixes that. The selector is now not applicable as optimisation occurs in a separate place. This change allows quoted images to be opened in a lightbox.
This commit is contained in:
@ -209,7 +209,7 @@ class CookedPostProcessor
|
|||||||
|
|
||||||
return if upload.animated?
|
return if upload.animated?
|
||||||
|
|
||||||
if img.ancestors(".onebox, .onebox-body, .quote").blank? && !img.classes.include?("onebox")
|
if img.ancestors(".onebox, .onebox-body").blank? && !img.classes.include?("onebox")
|
||||||
add_lightbox!(img, original_width, original_height, upload, cropped: crop)
|
add_lightbox!(img, original_width, original_height, upload, cropped: crop)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1012,7 +1012,7 @@ RSpec.describe CookedPostProcessor do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "optimizes images in quotes" do
|
it "optimizes and wraps images in quotes with lightbox wrapper" do
|
||||||
post = Fabricate(:post, raw: <<~MD)
|
post = Fabricate(:post, raw: <<~MD)
|
||||||
[quote]
|
[quote]
|
||||||

|

|
||||||
@ -1023,7 +1023,7 @@ RSpec.describe CookedPostProcessor do
|
|||||||
cpp.post_process
|
cpp.post_process
|
||||||
|
|
||||||
doc = Nokogiri::HTML5.fragment(cpp.html)
|
doc = Nokogiri::HTML5.fragment(cpp.html)
|
||||||
expect(doc.css(".lightbox-wrapper").size).to eq(0)
|
expect(doc.css(".lightbox-wrapper").size).to eq(1)
|
||||||
expect(doc.css("img").first["srcset"]).to_not eq(nil)
|
expect(doc.css("img").first["srcset"]).to_not eq(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user