Skip to content

Commit

Permalink
Use SVG cleaner on favicons
Browse files Browse the repository at this point in the history
Signed-off-by: snipe <[email protected]>
  • Loading branch information
snipe committed Mar 1, 2024
1 parent b1cd443 commit aaae952
Showing 1 changed file with 6 additions and 27 deletions.
33 changes: 6 additions & 27 deletions app/Http/Controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ public function postBranding(ImageUploadRequest $request)

// Only allow the site name and CSS to be changed if lock_passwords is false
// Because public demos make people act like dicks

if (! config('app.lock_passwords')) {
$setting->site_name = $request->input('site_name');
$setting->custom_css = $request->input('custom_css');
Expand All @@ -444,44 +445,22 @@ public function postBranding(ImageUploadRequest $request)
}



$setting = $request->handleImages($setting, 600, 'label_logo', '', 'label_logo');

if ('1' == $request->input('clear_label_logo')) {
Storage::disk('public')->delete($setting->label_logo);
$setting->label_logo = null;
}


// If the user wants to clear the favicon...
if ($request->hasFile('favicon')) {
$favicon_image = $favicon_upload = $request->file('favicon');
$favicon_ext = $favicon_image->getClientOriginalExtension();
$setting->favicon = $favicon_file_name = 'favicon-uploaded.'.$favicon_ext;

if (($favicon_image->getClientOriginalExtension() != 'ico') && ($favicon_image->getClientOriginalExtension() != 'svg')) {
$favicon_upload = Image::make($favicon_image->getRealPath())->resize(null, 36, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});

// This requires a string instead of an object, so we use ($string)
Storage::disk('public')->put($favicon_file_name, (string) $favicon_upload->encode());
} else {
Storage::disk('public')->put($favicon_file_name, file_get_contents($request->file('favicon')));
}

$setting = $request->handleImages($setting, 600, 'favicon', '', 'favicon');

// Remove Current image if exists
if (($setting->favicon) && (file_exists($favicon_file_name))) {
Storage::disk('public')->delete($favicon_file_name);
}
} elseif ('1' == $request->input('clear_favicon')) {
Storage::disk('public')->delete($setting->clear_favicon);
// If the user wants to clear the favicon...
if ('1' == $request->input('clear_favicon')) {
Storage::disk('public')->delete($setting->favicon);
$setting->favicon = null;

// If they are uploading an image, validate it and upload it
}

}

if ($setting->save()) {
Expand Down

0 comments on commit aaae952

Please sign in to comment.