Skip to content

Commit

Permalink
Feat: support relative media paths via config
Browse files Browse the repository at this point in the history
  • Loading branch information
awcodes committed Nov 2, 2023
1 parent e5c4950 commit 88aa410
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions config/filament-tiptap-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
'image_crop_aspect_ratio' => null,
'image_resize_target_width' => null,
'image_resize_target_height' => null,
'use_relative_paths' => true,

/*
|--------------------------------------------------------------------------
Expand Down
10 changes: 7 additions & 3 deletions src/Actions/MediaAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,13 @@ protected function setUp(): void
->default('document'),
];
})->action(function (TiptapEditor $component, $data) {
$source = str_starts_with($data['src'], 'http')
? $data['src']
: Storage::disk(config('filament-tiptap-editor.disk'))->url($data['src']);
if (config('filament-tiptap-editor.use_relative_paths')) {
$source = Str::replace(config('app.url'), '', $data['src']);
} else {
$source = str_starts_with($data['src'], 'http')
? $data['src']
: Storage::disk(config('filament-tiptap-editor.disk'))->url($data['src']);
}

$component->getLivewire()->dispatch(
'insert-media',
Expand Down

0 comments on commit 88aa410

Please sign in to comment.