@@ -32,25 +32,32 @@ def summary(self):
3232 def get_cropped_path (self , width , height ):
3333 id = str (self .id )
3434 thumbnail_folder = self .filer_public_thumbnails / f'{ id [0 :2 ]} /{ id [2 :4 ]} /{ id } '
35- thumbnail_path = Path (self .file_name )
35+ file_name = Path (self .file_name )
3636 crop_x , crop_y , crop_size , gravity = (
3737 self .meta_data .get ('crop_x' ),
3838 self .meta_data .get ('crop_y' ),
3939 self .meta_data .get ('crop_size' ),
4040 self .meta_data .get ('gravity' ),
4141 )
4242 if crop_x is None or crop_y is None or crop_size is None :
43- thumbnail_path_template = '{stem}__{width}x{height}{suffix}'
43+ cropped_path_template = '{stem}__{width}x{height}{suffix}'
4444 else :
4545 crop_x , crop_y , crop_size = int (crop_x ), int (crop_y ), int (crop_size )
46- thumbnail_path_template = '{stem}__{width}x{height}__{crop_x}_{crop_y}_{crop_size}{gravity}{suffix}'
47- return thumbnail_folder / thumbnail_path_template .format (
48- stem = thumbnail_path .stem ,
46+ cropped_path_template = '{stem}__{width}x{height}__{crop_x}_{crop_y}_{crop_size}{gravity}{suffix}'
47+ return thumbnail_folder / cropped_path_template .format (
48+ stem = file_name .stem ,
4949 width = round (width ),
5050 height = round (height ),
5151 crop_x = crop_x ,
5252 crop_y = crop_y ,
5353 crop_size = crop_size ,
5454 gravity = gravity or '' ,
55- suffix = thumbnail_path .suffix ,
55+ suffix = file_name .suffix ,
5656 )
57+
58+ def get_meta_data (self ):
59+ return {
60+ 'orig_width' : self .width ,
61+ 'orig_height' : self .height ,
62+ 'alt_text' : self .meta_data .get ('alt_text' , self .name ),
63+ }
0 commit comments