Get the URL of protected assets through the Backend Files controller if available.

This commit is contained in:
Luke Towers 2019-01-15 14:25:26 -06:00
parent 2758c6711b
commit 4f7c5cc1e7
1 changed files with 30 additions and 0 deletions

View File

@ -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.
*/