From 96191a5e9391e86701095b74fefc9064e4bf74d3 Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 17 Oct 2024 00:07:54 +0100 Subject: [PATCH] Added method to decide if the file should be inlinable Signed-off-by: snipe --- app/Helpers/StorageHelper.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/Helpers/StorageHelper.php b/app/Helpers/StorageHelper.php index 2cdab1d66c..0b56aa97cd 100644 --- a/app/Helpers/StorageHelper.php +++ b/app/Helpers/StorageHelper.php @@ -25,4 +25,25 @@ class StorageHelper return Storage::disk($disk)->download($filename); } } + + public static function allowSafeInline($file_with_path) { + + $allowed_inline = [ + 'pdf', + 'svg', + 'jpg', + 'gif', + 'svg', + 'avif', + 'webp', + 'png', + ]; + + if (in_array(pathinfo($file_with_path, PATHINFO_EXTENSION), $allowed_inline)) { + return true; + } + + return false; + + } }