Preload ThemeImages svgs

- Send svg content on initial theme images call
- Load and cache on Theme images call
This commit is contained in:
Clemente Raposo 2021-10-19 12:53:44 +01:00 committed by c.raposo
parent b7860e4246
commit 6317b37830
3 changed files with 32 additions and 5 deletions

View file

@ -114,7 +114,8 @@ class ThemeImageService
{
$path = $this->buildPath($imagePath, $theme);
$fullPath = $this->projectDir . '/public/' . $path;
$basePath = $this->projectDir . '/public/';
$fullPath = $basePath . $path;
$it = $this->themeImageFinder->find($fullPath);
@ -134,10 +135,16 @@ class ThemeImageService
continue;
}
$content = '';
if ($extension === 'svg' && file_exists($file->getRealPath())) {
$content = file_get_contents($file->getRealPath());
}
$images[$name] = [
'path' => $filePath,
'name' => $name,
'type' => $extension
'type' => $extension,
'content' => $content
];
}