Rails 6.1.4 - Ruby 3.0.1 - ActiveStorage and WebP image format

Viewed 331

There is no good info about how to setup Rails for serving WebP images with ActiveStorage.

Can someone explain how to do it?

I try:

application.rb

config.active_storage.web_image_content_types = %w(image/jpeg image/png image/webp 
image/jpg)

And in View:

<% image_tag( f.image_1.variant(resize_to_limit: [800,600], format: :webp) ) %>

But this works on development ( I see link to jpeg but when I use right mouse button and "save image as" image is saved as .WebP

On production I see no image default icon for browser and link to .jpg

RoR is dead...

1 Answers

can use 'convert'

image.variant(resize_to_limit: [800,600], convert: :webp)
Related