Django: How do I change an image type to WebP in upload?

Viewed 105

I have a website that has a blog, and the upload images are served just right but the image format slows down the website and I wanted to make them all be converted to WebP, which loads faster, on upload, is there any way to do that?

my image field:

from django_resized import ResizedImageField

class Post(models.Model)
    image = ResizedImageField(size=[600, 500], quality=100, upload_to ='media/', default = 'media/placeholder.png')
1 Answers

Pretty sure all you have to do is add force_format="WEBP" to image

image = ResizedImageField(force_format="WEBP", size=[600, 500], quality=100, upload_to ='media/', default = 'media/placeholder.png')

Probably want to change the default to .webp, too!

Related