mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 14:07:30 +08:00
FIX: don't use srcset on cropped thumbnails
This commit is contained in:
@ -58,10 +58,10 @@ describe CookedPostProcessor do
|
||||
end
|
||||
|
||||
context "responsive images" do
|
||||
|
||||
before { SiteSetting.responsive_post_image_sizes = "1|1.5|3" }
|
||||
|
||||
it "includes responsive images on demand" do
|
||||
|
||||
SiteSetting.responsive_post_image_sizes = "1|1.5|3"
|
||||
|
||||
upload = Fabricate(:upload, width: 2000, height: 1500, filesize: 10000)
|
||||
post = Fabricate(:post, raw: "hello <img src='#{upload.url}'>")
|
||||
|
||||
@ -93,8 +93,29 @@ describe CookedPostProcessor do
|
||||
cpp.post_process_images
|
||||
|
||||
# 1.5x is skipped cause we have a missing thumb
|
||||
expect(cpp.html).to include('srcset="http://a.b.c/666x500.jpg, http://a.b.c/1998x1500.jpg 3.0x"')
|
||||
expect(cpp.html).to include('srcset="http://a.b.c/666x500.jpg, http://a.b.c/1998x1500.jpg 3x"')
|
||||
end
|
||||
|
||||
it "doesn't include response images for cropped images" do
|
||||
upload = Fabricate(:upload, width: 200, height: 4000, filesize: 12345)
|
||||
post = Fabricate(:post, raw: "hello <img src='#{upload.url}'>")
|
||||
|
||||
# fake some optimized images
|
||||
OptimizedImage.create!(
|
||||
url: 'http://a.b.c/200x500.jpg',
|
||||
width: 200,
|
||||
height: 500,
|
||||
upload_id: upload.id,
|
||||
sha1: SecureRandom.hex,
|
||||
extension: '.jpg',
|
||||
filesize: 500
|
||||
)
|
||||
|
||||
cpp = CookedPostProcessor.new(post)
|
||||
cpp.add_to_size_cache(upload.url, 200, 4000)
|
||||
cpp.post_process_images
|
||||
|
||||
expect(cpp.html).to_not include('srcset="')
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user