Remove metadata from images

Currently in the application we never show the original image, we always
show one of its variants.

This change removes the metadata of both the variants and the original
version so that if at some point we decide to show the original version,
we will no longer have to remember to remove the metadata.
This commit is contained in:
taitus
2023-06-05 15:55:53 +02:00
committed by Javi Martín
parent 1392733dbc
commit 78ee45630b
3 changed files with 27 additions and 2 deletions

View File

@@ -41,9 +41,9 @@ class Image < ApplicationRecord
def variant(style) def variant(style)
if style if style
attachment.variant(self.class.styles[style]) attachment.variant(self.class.styles[style].merge(strip: true))
else else
attachment attachment.variant(strip: true)
end end
end end

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

@@ -0,0 +1,25 @@
require "rails_helper"
describe "Images" do
before { Setting["uploads.images.min_height"] = 0 }
describe "Metadata" do
let(:image) { create(:image, attachment: fixture_file_upload("logo_header_with_metadata.jpg")) }
scenario "download original images without metadata" do
visit polymorphic_path(image.variant(nil))
file = MiniMagick::Image.open(page.find("img")["src"])
expect(file.exif).to be_empty
end
scenario "download transformed images without metadata" do
visit polymorphic_path(image.variant(:large))
file = MiniMagick::Image.open(page.find("img")["src"])
expect(file.exif).to be_empty
end
end
end