From c68340b5fbca9e40c285cd6f5c566c49f92ac742 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Tue, 15 Mar 2022 20:23:39 +0100 Subject: [PATCH 1/2] Add URL Callback --- src/Driver.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Driver.php b/src/Driver.php index 777ecb4..c09424e 100644 --- a/src/Driver.php +++ b/src/Driver.php @@ -62,7 +62,6 @@ public function __construct() 'glideKey' => null, 'imageManager' => null, 'cache' => 'session', // 'session', 'memory' or false - 'fscache' => null, // The Flysystem cache 'checkSubfolders' => false, // Disable for performance ); @@ -88,13 +87,13 @@ public function mount(array $opts) } /** - * Find the icon based on the used Adapter + * Return the icon * * @return string */ protected function getIcon() { - $icon = 'volume_icon_local.png'; + $icon = 'volume_icon_ftp.png'; $parentUrl = defined('ELFINDER_IMG_PARENT_URL') ? (rtrim(ELFINDER_IMG_PARENT_URL, '/') . '/') : ''; return $parentUrl . 'img/' . $icon; @@ -302,6 +301,10 @@ protected function _stat($path) } } + if ($this->options['URLCallback'] && is_callable($this->options['URLCallback'])) { + $stat['url'] = $this->options['URLCallback']($path); + } + return $stat; } @@ -828,11 +831,17 @@ public function getContentUrl($hash, $options = array()) return $url; } } + if (($file = $this->file($hash)) == false || !isset($file['url']) || !$file['url'] || $file['url'] == 1) { if ($file && !empty($file['url']) && !empty($options['temporary'])) { return parent::getContentUrl($hash, $options); } $path = $this->decode($hash); + + if ($this->options['URLCallback'] && is_callable($this->options['URLCallback'])) { + return $this->options['URLCallback']($path); + } + return parent::getContentUrl($hash, $options); } return $file['url']; From 52d7faa078540b581f1218fc7b7d999ccd581989 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Tue, 15 Mar 2022 20:26:23 +0100 Subject: [PATCH 2/2] Add default option --- src/Driver.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Driver.php b/src/Driver.php index c09424e..af14a0a 100644 --- a/src/Driver.php +++ b/src/Driver.php @@ -58,6 +58,7 @@ public function __construct() { $opts = array( 'filesystem' => null, + 'URLCallback' => null, 'glideURL' => null, 'glideKey' => null, 'imageManager' => null,