respondcreate / django-versatileimagefield

A drop-in replacement for django's ImageField that provides a flexible, intuitive and easily-extensible interface for quickly creating new images from the one assigned to the field.
http://django-versatileimagefield.readthedocs.io/
MIT License
531 stars 88 forks source link

using width_field and height_field cause remote storage loads to be unbearably slow #169

Open qosha1 opened 4 years ago

qosha1 commented 4 years ago

I'm not sure if this is an issue as much as just something i wanted to note for others using this.

I recently finally debugged an issue that took my site from a ~1s load time to 12-14s (good number of photos per page). Apparently when you load the width/height from the VersatileImageField to a model field and have the images on remote storage (im using amazon S3), it takes forever to load.

I ended up removing the height/width fields from the model and then just used the image.height / image.width method.

This suggested code in the docs was the culprit:

class ImageExampleModel(models.Model): name = models.CharField( 'Name', max_length=80 ) image = models.ImageField( 'Image', upload_to='images/testimagemodel/', width_field='width', height_field='height' ) height = models.PositiveIntegerField( 'Image Height', blank=True, null=True ) width = models.PositiveIntegerField( 'Image Width', blank=True, null=True )

Instead I used:

class ImageExampleModel(models.Model): name = models.CharField( 'Name', max_length=80 ) image = models.ImageField( 'Image', upload_to='images/testimagemodel/', )