mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-30 04:23:11 +03:00
Ensured base64 images are read from image upload folder
Also removed unused storage systems and updated testing.
This commit is contained in:
@ -42,13 +42,6 @@ return [
|
||||
'root' => storage_path(),
|
||||
],
|
||||
|
||||
'ftp' => [
|
||||
'driver' => 'ftp',
|
||||
'host' => 'ftp.example.com',
|
||||
'username' => 'your-username',
|
||||
'password' => 'your-password',
|
||||
],
|
||||
|
||||
's3' => [
|
||||
'driver' => 's3',
|
||||
'key' => env('STORAGE_S3_KEY', 'your-key'),
|
||||
@ -59,16 +52,6 @@ return [
|
||||
'use_path_style_endpoint' => env('STORAGE_S3_ENDPOINT', null) !== null,
|
||||
],
|
||||
|
||||
'rackspace' => [
|
||||
'driver' => 'rackspace',
|
||||
'username' => 'your-username',
|
||||
'key' => 'your-key',
|
||||
'container' => 'your-container',
|
||||
'endpoint' => 'https://identity.api.rackspacecloud.com/v2.0/',
|
||||
'region' => 'IAD',
|
||||
'url_type' => 'publicURL',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
|
@ -450,28 +450,32 @@ class ImageService
|
||||
|
||||
/**
|
||||
* Get a storage path for the given image URL.
|
||||
* Ensures the path will start with "uploads/images".
|
||||
* Returns null if the url cannot be resolved to a local URL.
|
||||
*/
|
||||
private function imageUrlToStoragePath(string $url): ?string
|
||||
{
|
||||
$url = trim($url);
|
||||
$url = ltrim(trim($url), '/');
|
||||
|
||||
// Handle potential relative paths
|
||||
$isRelative = strpos($url, 'http') !== 0;
|
||||
if ($isRelative) {
|
||||
return trim($url, '/');
|
||||
if (strpos(strtolower($url), 'uploads/images') === 0) {
|
||||
return trim($url, '/');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Handle local images based on paths on the same domain
|
||||
$potentialHostPaths = [
|
||||
url('/'),
|
||||
$this->getPublicUrl('/'),
|
||||
url('uploads/images/'),
|
||||
$this->getPublicUrl('/uploads/images/'),
|
||||
];
|
||||
|
||||
foreach ($potentialHostPaths as $potentialBasePath) {
|
||||
$potentialBasePath = strtolower($potentialBasePath);
|
||||
if (strpos(strtolower($url), $potentialBasePath) === 0) {
|
||||
return trim(substr($url, strlen($potentialBasePath)), '/');
|
||||
return 'uploads/images/' . trim(substr($url, strlen($potentialBasePath)), '/');
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user