Add max_bytes to imgproxy. (#12110)
* Add format to image optimizer * Only use max bytes * Fix show view spec
This commit is contained in:
parent
4db300e348
commit
1a25fb3542
3 changed files with 4 additions and 3 deletions
|
|
@ -34,6 +34,7 @@ module Images
|
|||
DEFAULT_IMGPROXY_OPTIONS = {
|
||||
height: nil,
|
||||
width: nil,
|
||||
max_bytes: 500_000, # Keep everything under half of one MB.
|
||||
resizing_type: nil
|
||||
}.freeze
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ RSpec.describe Images::Optimizer, type: :service do
|
|||
it "works" do
|
||||
allow(described_class).to receive(:imgproxy_enabled?).and_return(true)
|
||||
imgproxy_url = described_class.imgproxy(image_url, service: :imgproxy, width: 500, height: 500)
|
||||
expect(imgproxy_url).to match(%r{/s:500:500/aHR0cHM6Ly9pLmlt/Z3VyLmNvbS9mS1lL/Z280LnBuZw})
|
||||
expect(imgproxy_url).to match(%r{/s:500:500/mb:500000/aHR0cHM6Ly9pLmlt/Z3VyLmNvbS9mS1lL/Z280LnBuZw})
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ RSpec.describe Images::Optimizer, type: :service do
|
|||
end
|
||||
|
||||
describe "#translate_cloudinary_options" do
|
||||
it "Set resizing_type to fill if crop: fill is provided" do
|
||||
it "sets resizing_type to fill if crop: fill is provided" do
|
||||
options = { width: 100, height: 100, crop: "fill" }
|
||||
expect(described_class.translate_cloudinary_options(options)).to include(resizing_type: "fill")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ RSpec.describe "dashboards/show.html.erb", type: :view do
|
|||
assign(:user, create(:user))
|
||||
assign(:articles, [])
|
||||
render
|
||||
expect(rendered).to match(%r{/w:300/aHR0cHM6Ly9pLmlt/Z3VyLmNvbS9mS1lL/Z280LnBuZw})
|
||||
expect(rendered).to match(%r{/w:300/mb:500000/aHR0cHM6Ly9pLmlt/Z3VyLmNvbS9mS1lL/Z280LnBuZw})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue