diff --git a/app/models/concerns/alchemy/picture_thumbnails.rb b/app/models/concerns/alchemy/picture_thumbnails.rb index ef3a234e81..cffc857407 100644 --- a/app/models/concerns/alchemy/picture_thumbnails.rb +++ b/app/models/concerns/alchemy/picture_thumbnails.rb @@ -84,7 +84,7 @@ def thumbnail_url_options crop_from: crop && crop_from.presence || default_crop_from&.join("x"), crop_size: crop && crop_size.presence || default_crop_size&.join("x"), flatten: true, - format: picture&.image_file_format || "jpg" + format: "webp" } end diff --git a/app/views/alchemy/admin/pictures/_picture.html.erb b/app/views/alchemy/admin/pictures/_picture.html.erb index 474f302453..7a1abac4c1 100644 --- a/app/views/alchemy/admin/pictures/_picture.html.erb +++ b/app/views/alchemy/admin/pictures/_picture.html.erb @@ -20,7 +20,7 @@ <% end %> - <% picture_url = picture.url(size: preview_size(@size), flatten: true) %> + <% picture_url = picture.url(size: preview_size(@size), flatten: true, format: "webp") %> <% image = image_tag(picture_url || "alchemy/missing-image.svg", alt: picture.name) %> <% if can?(:edit, picture) && picture_url %> <%= link_to( diff --git a/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb b/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb index 2ccdaaf993..0443754ec8 100644 --- a/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +++ b/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb @@ -2,7 +2,7 @@ <%= link_to( image_tag( - picture_to_assign.url(size: preview_size(size), flatten: true) || "alchemy/missing-image.svg", + picture_to_assign.url(size: preview_size(size), flatten: true, format: "webp") || "alchemy/missing-image.svg", alt: picture_to_assign.name ), alchemy.assign_admin_picture_path( diff --git a/lib/alchemy/test_support/having_picture_thumbnails_examples.rb b/lib/alchemy/test_support/having_picture_thumbnails_examples.rb index f15af61e0a..ee551bec7d 100644 --- a/lib/alchemy/test_support/having_picture_thumbnails_examples.rb +++ b/lib/alchemy/test_support/having_picture_thumbnails_examples.rb @@ -203,8 +203,8 @@ allow(record).to receive(:settings) { settings } end - it "includes the image's original file format." do - expect(thumbnail_url).to match(/\.png/) + it "includes webp file format." do + expect(thumbnail_url).to match(/\.webp/) end it "flattens the image." do @@ -305,8 +305,8 @@ create(:alchemy_picture) end - it "includes the image's original file format." do - expect(thumbnail_url_options[:format]).to eq("png") + it "uses webp image format." do + expect(thumbnail_url_options[:format]).to eq("webp") end it "flattens the image." do @@ -381,7 +381,7 @@ crop_from: nil, crop_size: nil, flatten: true, - format: "jpg", + format: "webp", size: "160x120" ) end @@ -400,7 +400,7 @@ crop_from: nil, crop_size: nil, flatten: true, - format: "jpg", + format: "webp", size: "160x120" ) end