Skip to content

Commit

Permalink
Add newly filemanager concept support for post-module
Browse files Browse the repository at this point in the history
  • Loading branch information
dannyatthaya committed Aug 6, 2021
1 parent 56d8635 commit 0f1a2cc
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/Helpers/HandleFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,22 @@ public static function handle($dto)

protected static function handleUrl($val)
{
$exploded = explode('.', $val);
$extension = end($exploded);
if (in_array($extension, ['jpg', 'jpeg', 'gif', 'png', 'bmp', 'svg', 'ico', 'tif', 'tiff', 'webp', 'heif']) && filter_var($val, FILTER_VALIDATE_URL) === false) {
if (stristr($val, 'http://') ?: stristr($val, 'https://')) {
return $val;
}

if (preg_match('/^.*\.(jpg|jpeg|gif|svg|ico|tif|tiff|webp|heif|png|bmp)$/i', $val)) {
return Storage::url($val);
}

if (Str::contains($val, config('lfm.folder_categories.file.folder_name') . '/')) {
return str_replace(
config('lfm.folder_categories.file.folder_name') . '/',
Storage::url('/') . config('lfm.folder_categories.file.folder_name') . '/',
$val
);
}

return $val;
}

Expand Down

0 comments on commit 0f1a2cc

Please sign in to comment.