1

How do I fill in the ProcessedImageField after saving the original image?

I tried to override the save method, smth like this:

class A(models.Model):
    original = models.ImageField()
    webp_1x = ProcessedImageField(format='WEBP', processors=[ResizeToFit(320, 320), null=True, blank=True)
    webp_2x = ProcessedImageField(format='WEBP', processors=[ResizeToFit(640, 640)], null=True, blank=True)

    def save(self, *args, **kwargs):
        self.webp_1x = self.original
        self.webp_2x = self.original
        super().save(*args, **kwargs)

But it doesn't work. Unfortunately, there is no argument source in ProcessedImageField

Sh VavilenT
  • 337
  • 2
  • 9

0 Answers0