File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change 1212
1313
1414def _process_picture (field_file : PictureFieldFile ) -> None :
15- field_file .open () # the file needs to be open
16- with Image .open (field_file .file ) as img :
17- for ratio , sources in field_file .aspect_ratios .items ():
18- for file_type , srcset in sources .items ():
19- for width , picture in srcset .items ():
20- picture .save (img )
15+ # field_file.file may already be closed and can't be reopened.
16+ # Therefore, we always open it from storage.
17+ with field_file .storage .open (field_file .name ) as fs :
18+ with Image .open (fs ) as img :
19+ for ratio , sources in field_file .aspect_ratios .items ():
20+ for file_type , srcset in sources .items ():
21+ for width , picture in srcset .items ():
22+ picture .save (img )
2123
2224
2325process_picture = _process_picture
You can’t perform that action at this time.
0 commit comments