From 4b40d13cb37a465cc334e20d8131070c8a23d268 Mon Sep 17 00:00:00 2001 From: Claire Date: Sat, 14 Sep 2024 02:16:02 +0200 Subject: [PATCH] Increase preview card image size limit from 2MB to 8MB when using libvips (#31904) --- app/models/preview_card.rb | 2 +- spec/models/preview_card_spec.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/preview_card.rb b/app/models/preview_card.rb index 5a11351e58..7579178f83 100644 --- a/app/models/preview_card.rb +++ b/app/models/preview_card.rb @@ -39,7 +39,7 @@ class PreviewCard < ApplicationRecord include Attachmentable IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].freeze - LIMIT = 2.megabytes + LIMIT = Rails.configuration.x.use_vips ? 8.megabytes : 2.megabytes BLURHASH_OPTIONS = { x_comp: 4, diff --git a/spec/models/preview_card_spec.rb b/spec/models/preview_card_spec.rb index 2f0ea38ee4..c0bc2b6e0e 100644 --- a/spec/models/preview_card_spec.rb +++ b/spec/models/preview_card_spec.rb @@ -3,6 +3,12 @@ require 'rails_helper' RSpec.describe PreviewCard do + describe 'file size limit', :attachment_processing do + it 'is set differently whether vips is enabled or not' do + expect(described_class::LIMIT).to eq(Rails.configuration.x.use_vips ? 8.megabytes : 2.megabytes) + end + end + describe 'validations' do describe 'urls' do it 'allows http schemes' do