-
-
Notifications
You must be signed in to change notification settings - Fork 227
Closed
Description
- Winter CMS Build: 1.1.3
- PHP Version:
- Database Engine: mysql
- Plugins Installed:
Description:
When Winter is installed as a subdirectory and you try to use resizer to resize images in your theme or component, you get a 404 because it tries to find the URL /resizer/d2...cf1/%252Fstorage%252Fapp%252....
Steps To Reproduce:
- install wintercms as a subdirectory of a site.
- try to resize an image on the theme using the
<img src="{{ 'image.jpg' | media | resize(300,300) }}" />
Suggested Fix:
I identified that modules/system/classes/imageResizer.php has two points where it returns an URL without adding the app path:
in public function getResizerUrl (line ~502)
and sequentially where it returns an already resized image in public function getResizedUrl() (line ~532)
/**
* Get the URL to the system resizer route for this instance's configuration
*
* @return string $url
*/
public function getResizerUrl()
{
// Slashes in URL params have to be double encoded to survive Laravel's router
// @see https://github.com/octobercms/october/issues/3592#issuecomment-671017380
$resizedUrl = rawurlencode(rawurlencode($this->getResizedUrl()));
// Get the current configuration's identifier
$identifier = $this->getIdentifier();
// Store the current configuration
$this->storeConfig();
// IF YOU ADD THE CONFIG::GET APP.URL IT WORKS
$url = Config::get('app.url','')."/resizer/$identifier/$resizedUrl";
if (Config::get('cms.linkPolicy', 'detect') === 'force') {
$url = Url::to($url);
}
return $url;
}
/**
* Get the URL to the resized image
*
* @return string
*/
public function getResizedUrl()
{
$url = '';
if ($this->image['source'] === 'filemodel') {
$model = $this->getFileModel();
$thumbFile = $model->getThumbFilename($this->width, $this->height, $this->options);
$url = $model->getPath($thumbFile);
} else {
$resizedDisk = Storage::disk(Config::get('cms.storage.resized.disk', 'local'));
$url = $resizedDisk->url($this->getPathToResizedImage());
}
// Ensure that a properly encoded URL is returned
$segments = explode('/', $url);
$lastSegment = array_pop($segments);
// AGAIN HERE - ADDING THE APPURL WORKS TOO
$url = Config::get('app.url','').implode('/', $segments) . '/' . rawurlencode(rawurldecode($lastSegment));
if (Config::get('cms.linkPolicy', 'detect') === 'force') {
$url = Url::to($url);
}
return $url;
}Metadata
Metadata
Assignees
Labels
No labels