Skip to content

Commit

Permalink
Use WebP for all thumbnails
Browse files Browse the repository at this point in the history
WebP is well supported and is much more efficient than
png or jpg.
  • Loading branch information
tvdeyen committed Jan 6, 2024
1 parent 4256c1b commit 3d7979a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/concerns/alchemy/picture_thumbnails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/views/alchemy/admin/pictures/_picture.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</sl-tooltip>
</span>
<% 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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<sl-tooltip content="<%= Alchemy.t(:assign_image) %>">
<%= 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(
Expand Down

0 comments on commit 3d7979a

Please sign in to comment.