From c54b3d92d1d18ad5eda8e53595ad7ca52c17ec2a Mon Sep 17 00:00:00 2001 From: Naoki Sawada Date: Mon, 16 Jul 2018 21:44:30 +0900 Subject: [PATCH] support an option `'temporary'` of getContentUrl() In the `getContentUrl()` function, if the option `temporary` is specified, it is necessary to call the inheriting function. --- src/Driver.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Driver.php b/src/Driver.php index 33c36f8..16cd065 100644 --- a/src/Driver.php +++ b/src/Driver.php @@ -800,8 +800,15 @@ public function getImageSize($path, $mime = '') public function getContentUrl($hash, $options = array()) { 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); - return $this->fs->getUrl($path); + if ($res = $this->fs->getUrl($path) || empty($options['temporary'])) { + return $res; + } else { + return parent::getContentUrl($hash, $options); + } } return $file['url']; }