@@ -108,8 +108,9 @@ public function createEntry(array $current): void
108
108
109
109
/* Titelbild abrufen und speichern */
110
110
$ updated_image = '' ;
111
- $ targetname = $ entry_data ['uuid ' ] . '_ ' . $ entry_data ['image ' ];
112
- if ($ this ->createMedia ($ entry_data ['image ' ])) {
111
+ $ prefix = $ this ->getParam ('media_prefix ' ) ? $ entry_data ['uuid ' ] . '_ ' : '' ;
112
+ $ targetname = $ prefix . $ entry_data ['image ' ];
113
+ if ($ this ->createMedia ($ entry_data ['image ' ], $ prefix )) {
113
114
$ updated_image = $ targetname ;
114
115
}
115
116
$ entry ->setValue ('image ' , $ updated_image );
@@ -119,8 +120,8 @@ public function createEntry(array $current): void
119
120
$ images = array_filter (explode (', ' , $ entry_data ['images ' ]));
120
121
$ updated_images = [];
121
122
foreach ($ images as $ image ) {
122
- $ targetname = $ entry_data [ ' uuid ' ] . ' _ ' . $ image ;
123
- if ($ this ->createMedia ($ image , $ targetname )) {
123
+ $ targetname = $ prefix . $ image ;
124
+ if ($ this ->createMedia ($ image , $ prefix )) {
124
125
$ updated_images [] = $ targetname ;
125
126
}
126
127
}
@@ -187,9 +188,9 @@ public function createAuthor(array $current): Author
187
188
return $ author ;
188
189
}
189
190
190
- public function createMedia (string $ filename , ? string $ prefix = null ): bool
191
+ public function createMedia (string $ filename , string $ prefix = '' ): bool
191
192
{
192
- $ targetname = rex_string::normalize ($ prefix) . $ filename ;
193
+ $ targetname = rex_string::normalize ($ prefix . $ filename) ;
193
194
if ('' === $ filename ) {
194
195
return false ;
195
196
}
@@ -281,6 +282,15 @@ public function getParamFields()
281
282
'type ' => 'text ' ,
282
283
'attributes ' => ['type ' => 'number ' , 'min ' => 1 ],
283
284
],
285
+ [
286
+ 'name ' => 'media_prefix ' ,
287
+ 'label ' => rex_i18n::msg ('neues_entry_sync_cronjob_media_prefix ' ),
288
+ 'type ' => 'select ' ,
289
+ 'options ' => [
290
+ '1 ' => rex_i18n::msg ('neues_entry_sync_cronjob_media_prefix_yes ' ),
291
+ '0 ' => rex_i18n::msg ('neues_entry_sync_cronjob_media_prefix_no ' ),
292
+ ],
293
+ ],
284
294
];
285
295
286
296
return $ fields ;
0 commit comments