mirror of
https://github.com/django/django.git
synced 2025-01-18 22:33:44 +00:00
bcacc6321a
This avoids reading the image size when the dimensions fields (image_width, image_height) do not exist, as that operation may be expensive. Partially reverts ea53e7c09f1b8864c20c65976bbeaeab77abdaec, that dropped the check for the dimension fields in update_dimension_fields(), because the post_init signal was no longer registered without dimension fields. However, another code path to that function exists: when the ImageFileField is save()d, the name from the storage is setattr()ed on the field, and ImageFileDescriptor calls update_dimension_fields() because the image size might have changed. Keep bailing out early when dimensions are unused. Besides, computing the image dimensions causes to close() the file, resulting in a backward-incompatible change. The test protects against that change.