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:
@@ -41,9 +41,9 @@ class Image < ApplicationRecord
|
||||
|
||||
def variant(style)
|
||||
if style
|
||||
attachment.variant(self.class.styles[style])
|
||||
attachment.variant(self.class.styles[style].merge(strip: true))
|
||||
else
|
||||
attachment
|
||||
attachment.variant(strip: true)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
BIN
spec/fixtures/files/logo_header_with_metadata.jpg
vendored
Normal file
BIN
spec/fixtures/files/logo_header_with_metadata.jpg
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.5 KiB |
25
spec/system/images_spec.rb
Normal file
25
spec/system/images_spec.rb
Normal 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
|
||||
Reference in New Issue
Block a user