diff --git a/lib/upload_creator.rb b/lib/upload_creator.rb index 991c3151772..a5352c995c0 100644 --- a/lib/upload_creator.rb +++ b/lib/upload_creator.rb @@ -168,6 +168,8 @@ class UploadCreator @upload.errors.add(:base, I18n.t("upload.empty")) elsif pixels == 0 @upload.errors.add(:base, I18n.t("upload.images.size_not_found")) + elsif max_image_pixels > 0 && pixels >= max_image_pixels * 2 + @upload.errors.add(:base, I18n.t("upload.images.larger_than_x_megapixels", max_image_megapixels: SiteSetting.max_image_megapixels * 2)) end end diff --git a/spec/fixtures/images/huge.jpg b/spec/fixtures/images/huge.jpg index 25f2d5c6fb4..2fb791c8162 100644 Binary files a/spec/fixtures/images/huge.jpg and b/spec/fixtures/images/huge.jpg differ diff --git a/spec/models/upload_spec.rb b/spec/models/upload_spec.rb index 23d79fc4692..3415363b6b6 100644 --- a/spec/models/upload_spec.rb +++ b/spec/models/upload_spec.rb @@ -56,11 +56,11 @@ describe Upload do upload = Upload.find(upload.id) - expect(upload.width).to eq(64250) - expect(upload.height).to eq(64250) + expect(upload.width).to eq(8900) + expect(upload.height).to eq(8900) upload.reload - expect(upload.read_attribute(:width)).to eq(64250) + expect(upload.read_attribute(:width)).to eq(8900) upload.update_columns(width: nil, height: nil, thumbnail_width: nil, thumbnail_height: nil)