Loading modules/Media/FileManagers/FS.php +1 −8 Original line number Diff line number Diff line Loading @@ -57,14 +57,7 @@ class FS implements FileManagerInterface public function getUrl(string $key): string { $appConfig = config('App'); $mediaBaseUrl = $this->config->baseURL === '' ? $appConfig->baseURL : $this->config->baseURL; return rtrim((string) $mediaBaseUrl, '/') . '/' . $this->config->root . '/' . $key; return media_url($this->config->root . '/' . $key); } public function rename(string $oldKey, string $newKey): bool Loading modules/Media/FileManagers/S3.php +1 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ class S3 implements FileManagerInterface public function getUrl(string $key): string { return url_to('media-serve', $key); return media_url((string) route_to('media-serve', $key)); } public function rename(string $oldKey, string $newKey): bool Loading modules/Media/Helpers/url_helper.php 0 → 100644 +31 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); use CodeIgniter\HTTP\URI; use Modules\Media\Config\Media; if (! function_exists('media_url')) { /** * Returns a media URL as defined by the Media config. * * @param array|string $relativePath URI string or array of URI segments */ function media_url($relativePath = '', ?string $scheme = null): string { // Convert array of segments to a string if (is_array($relativePath)) { $relativePath = implode('/', $relativePath); } $uri = new URI(rtrim((string) config(Media::class)->baseURL, '/') . '/' . ltrim($relativePath)); return URI::createURIString( $scheme ?? $uri->getScheme(), $uri->getAuthority(), $uri->getPath(), $uri->getQuery(), $uri->getFragment() ); } } Loading
modules/Media/FileManagers/FS.php +1 −8 Original line number Diff line number Diff line Loading @@ -57,14 +57,7 @@ class FS implements FileManagerInterface public function getUrl(string $key): string { $appConfig = config('App'); $mediaBaseUrl = $this->config->baseURL === '' ? $appConfig->baseURL : $this->config->baseURL; return rtrim((string) $mediaBaseUrl, '/') . '/' . $this->config->root . '/' . $key; return media_url($this->config->root . '/' . $key); } public function rename(string $oldKey, string $newKey): bool Loading
modules/Media/FileManagers/S3.php +1 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ class S3 implements FileManagerInterface public function getUrl(string $key): string { return url_to('media-serve', $key); return media_url((string) route_to('media-serve', $key)); } public function rename(string $oldKey, string $newKey): bool Loading
modules/Media/Helpers/url_helper.php 0 → 100644 +31 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); use CodeIgniter\HTTP\URI; use Modules\Media\Config\Media; if (! function_exists('media_url')) { /** * Returns a media URL as defined by the Media config. * * @param array|string $relativePath URI string or array of URI segments */ function media_url($relativePath = '', ?string $scheme = null): string { // Convert array of segments to a string if (is_array($relativePath)) { $relativePath = implode('/', $relativePath); } $uri = new URI(rtrim((string) config(Media::class)->baseURL, '/') . '/' . ltrim($relativePath)); return URI::createURIString( $scheme ?? $uri->getScheme(), $uri->getAuthority(), $uri->getPath(), $uri->getQuery(), $uri->getFragment() ); } }