DEV: Allow for taller images in posts and oneboxes (#15395)
The previous default aspect ratio for cropping tall images was a little too strict and was cutting off images. This new setting should allow for a larger range of image sizes before cropping them.
This commit is contained in:
parent
19089f21d2
commit
b705971d42
|
@ -1431,7 +1431,7 @@ files:
|
|||
strip_image_metadata: true
|
||||
min_ratio_to_crop:
|
||||
type: float
|
||||
default: 0.45 # 90% of 18:9
|
||||
default: 0.22
|
||||
min: 0
|
||||
max: 1
|
||||
simultaneous_uploads:
|
||||
|
|
|
@ -535,8 +535,32 @@ describe CookedPostProcessor do
|
|||
end
|
||||
end
|
||||
|
||||
context "with tall images" do
|
||||
fab!(:upload) { Fabricate(:image_upload, width: 860, height: 2000) }
|
||||
context "with tall images > default aspect ratio" do
|
||||
fab!(:upload) { Fabricate(:image_upload, width: 500, height: 2200) }
|
||||
|
||||
fab!(:post) do
|
||||
Fabricate(:post, raw: <<~HTML)
|
||||
<img src="#{upload.url}">
|
||||
HTML
|
||||
end
|
||||
|
||||
let(:cpp) { CookedPostProcessor.new(post, disable_loading_image: true) }
|
||||
|
||||
before do
|
||||
SiteSetting.create_thumbnails = true
|
||||
end
|
||||
|
||||
it "resizes the image instead of crop" do
|
||||
cpp.post_process
|
||||
|
||||
expect(cpp.html).to match(/width="113" height="500">/)
|
||||
expect(cpp).to be_dirty
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "with taller images < default aspect ratio" do
|
||||
fab!(:upload) { Fabricate(:image_upload, width: 500, height: 2300) }
|
||||
|
||||
fab!(:post) do
|
||||
Fabricate(:post, raw: <<~HTML)
|
||||
|
@ -553,7 +577,7 @@ describe CookedPostProcessor do
|
|||
it "crops the image" do
|
||||
cpp.post_process
|
||||
|
||||
expect(cpp.html).to match(/width="690" height="500">/)
|
||||
expect(cpp.html).to match(/width="500" height="500">/)
|
||||
expect(cpp).to be_dirty
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue