From 4f7c5cc1e753817beda9b9c914d7d8b28b00dd2c Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Tue, 15 Jan 2019 14:25:26 -0600 Subject: [PATCH] Get the URL of protected assets through the Backend Files controller if available. --- modules/system/models/File.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/modules/system/models/File.php b/modules/system/models/File.php index 012342617..a4b72027c 100644 --- a/modules/system/models/File.php +++ b/modules/system/models/File.php @@ -19,6 +19,36 @@ class File extends FileBase */ protected $table = 'system_files'; + /** + * {@inheritDoc} + */ + public function getThumb($width, $height, $options = []) + { + $url = ''; + if (!$this->isPublic() && class_exists('\Backend\Controllers\Files')) { + $url = \Backend\Controllers\Files::getThumbUrl($this, $width, $height, $options); + } else { + $url = parent::getThumb($width, $height, $options); + } + + return $url; + } + + /** + * {@inheritDoc} + */ + public function getPath() + { + $url = ''; + if (!$this->isPublic() && class_exists('\Backend\Controllers\Files')) { + $url = \Backend\Controllers\Files::getDownloadUrl($this); + } else { + $url = parent::getPath(); + } + + return $url; + } + /** * If working with local storage, determine the absolute local path. */