mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-08-09 10:22:51 +03:00
Integrated favicon handler with correct files & actions
Format does not look 100% correct though, won't show in Firefox/gimp.
This commit is contained in:
@@ -51,6 +51,8 @@ class AppSettingsStore
|
||||
$this->destroyExistingSettingImage('app-icon-' . $size);
|
||||
setting()->remove('app-icon-' . $size);
|
||||
}
|
||||
|
||||
$this->faviconHandler->restoreOriginal();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -17,19 +17,32 @@ class FaviconHandler
|
||||
*/
|
||||
public function saveForUploadedImage(UploadedFile $file): void
|
||||
{
|
||||
$targetPath = public_path('favicon.ico');
|
||||
if (!is_writeable($targetPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$imageData = file_get_contents($file->getRealPath());
|
||||
$image = $this->imageTool->make($imageData);
|
||||
$image->resize(32, 32);
|
||||
$bmpData = $image->encode('bmp');
|
||||
$icoData = $this->bmpToIco($bmpData, 32, 32);
|
||||
|
||||
// TODO - Below are test paths
|
||||
file_put_contents(public_path('uploads/test.ico'), $icoData);
|
||||
file_put_contents(public_path('uploads/test.bmp'), $bmpData);
|
||||
file_put_contents($targetPath, $icoData);
|
||||
}
|
||||
|
||||
// TODO - Permission check for icon overwrite
|
||||
// TODO - Write to correct location
|
||||
// TODO - Handle deletion and restore of original icon on user icon clear
|
||||
/**
|
||||
* Restore the original favicon image.
|
||||
*/
|
||||
public function restoreOriginal(): void
|
||||
{
|
||||
$targetPath = public_path('favicon.ico');
|
||||
$original = public_path('icon.ico');
|
||||
if (!is_writeable($targetPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
copy($original, $targetPath);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user