[Answered ]-Change django picture img src in template based on min-width

1👍

you can create a custom filter

that accepts the image url and specific width and return the URL with the width plugged in.

def format_img_src(img_ur, size):
    """Returns an image of specific size"""
    # do your formatting here

0👍

class my_model_name(models.Model):
    ......
    image = models.ImageField(default='default.jpg', upload_to = '')

def save(self, *args, **kwargs):
    super(my_model_name, self).save(*args, **kwargs)
    img = Image.open(self.image.path)

    if img.height>300 or img.width > 300:
        img.thumbnail( (300,300) )
        img.save(self.image.path)

If you use this save mathod than your all img save 300*300.you can chane your size .

Leave a comment