@@ -50,7 +50,7 @@ def get_settings_defaults(self):
50
50
'inline_thumbnail_scale_value' : "50" , 'inline_thumbnail_position_left' : False ,
51
51
'align_inline_thumbnail' : False , 'inline_thumbnail_align_value' : "left" , 'state_panel_thumbnail' : True ,
52
52
'state_panel_thumbnail_scale_value' : "100" , 'resize_filelist' : False , 'filelist_height' : "306" ,
53
- 'scale_inline_thumbnail_position' : False , 'sync_on_refresh' : False }
53
+ 'scale_inline_thumbnail_position' : False , 'sync_on_refresh' : False , 'use_uploads_folder' : False }
54
54
55
55
# ~~ AssetPlugin mixin
56
56
@@ -205,20 +205,23 @@ def on_event(self, event, payload):
205
205
"type" ] and payload .get ("name" , False ):
206
206
thumbnail_name = self .regex_extension .sub (".png" , payload ["name" ])
207
207
thumbnail_path = self .regex_extension .sub (".png" , payload ["path" ])
208
- thumbnail_filename = "{}/{}" .format (self .get_plugin_data_folder (), thumbnail_path )
208
+ if not self ._settings .get_boolean (["use_uploads_folder" ]):
209
+ thumbnail_filename = "{}/{}" .format (self .get_plugin_data_folder (), thumbnail_path )
210
+ else :
211
+ thumbnail_filename = self ._file_manager .path_on_disk ("local" , thumbnail_path )
209
212
210
213
if os .path .exists (thumbnail_filename ):
211
214
os .remove (thumbnail_filename )
212
215
if event == "FileAdded" :
213
216
gcode_filename = self ._file_manager .path_on_disk ("local" , payload ["path" ])
214
217
self ._extract_thumbnail (gcode_filename , thumbnail_filename )
215
218
if os .path .exists (thumbnail_filename ):
216
- thumbnail_url = "plugin/prusaslicerthumbnails/thumbnail/{}?{:%Y%m%d%H%M%S}" . format (
217
- thumbnail_path .replace (thumbnail_name , quote (thumbnail_name )), datetime .datetime .now ())
218
- self . _file_manager . set_additional_metadata ( "local" , payload [ "path" ], "thumbnail" ,
219
- thumbnail_url . replace ( "//" , "/" ), overwrite = True )
220
- self ._file_manager .set_additional_metadata ("local" , payload ["path" ], "thumbnail_src" ,
221
- self ._identifier , overwrite = True )
219
+ if not self . _settings . get_boolean ([ "use_uploads_folder" ]):
220
+ thumbnail_url = "plugin/prusaslicerthumbnails/thumbnail/{}?{:%Y%m%d%H%M%S}" . format ( thumbnail_path .replace (thumbnail_name , quote (thumbnail_name )), datetime .datetime .now ())
221
+ else :
222
+ thumbnail_url = "downloads/files/local/{}?{:%Y%m%d%H%M%S}" . format ( thumbnail_path . replace ( thumbnail_name , quote ( thumbnail_name )), datetime . datetime . now () )
223
+ self ._file_manager .set_additional_metadata ("local" , payload ["path" ], "thumbnail" , thumbnail_url . replace ( "//" , "/" ), overwrite = True )
224
+ self . _file_manager . set_additional_metadata ( "local" , payload [ "path" ], "thumbnail_src" , self ._identifier , overwrite = True )
222
225
223
226
# ~~ SimpleApiPlugin mixin
224
227
0 commit comments