Skip to content

Commit 0c45ef5

Browse files
committed
update summernote image file name when attachment changes after cropping image
1 parent 7291525 commit 0c45ef5

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/Traits/Attachments.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,14 +358,23 @@ protected function updateAttachments($request, $a_result_errors, $attachments)
358358
$field = 'attachment_'.$att->id.'_image_crop';
359359
if ($request->has($field)){
360360
$a_fields['image_crop'] = $request->input($field);
361+
$original_filename = basename($att->file_path);
361362
}
362363

363364
if ($a_fields) $this->updateSingleAttachment($att, $a_fields, $a_single_errors);
364365

365366
if ($a_single_errors){
366367
$a_errors['attachment_block_'.$index] = implode('. ', $a_single_errors);
367368
}else{
369+
// Save attachment
368370
$att->save();
371+
372+
if ($a_fields and isset($a_fields['image_crop'])){
373+
// Update related Ticket or comment Html field
374+
$model = $att->comment_id == "" ? $att->ticket : $att->comment;
375+
$model->html = str_replace($original_filename, basename($att->file_path), $model->html);
376+
$model->save();
377+
}
369378
}
370379
$index++;
371380
}

0 commit comments

Comments
 (0)