Use image handling request for logo uploads

This commit is contained in:
snipe 2020-08-26 12:17:50 -07:00
parent a86dc52695
commit 24be73f76b
No known key found for this signature in database
GPG key ID: 10BFFDA3ED34B5AC

View file

@ -409,8 +409,8 @@ class SettingsController extends Controller
$setting->custom_css = $request->input('custom_css');
}
$setting = $request->handleImages($setting,600,'logo','', 'logo');
$setting = $request->handleImages('logo',600,'logo','', 'logo');
if ('1' == $request->input('clear_logo')) {
Storage::disk('public')->delete($setting->logo);
@ -419,66 +419,33 @@ class SettingsController extends Controller
}
if ($request->hasFile('email_logo')) {
$email_image = $email_upload = $request->file('email_logo');
$email_ext = $email_image->getClientOriginalExtension();
$setting->email_logo = $email_file_name = 'email_logo.' . $email_ext;
$setting = $request->handleImages($setting,600,'email_logo','', 'email_logo');
if ('svg' != $email_image->getClientOriginalExtension()) {
$email_upload = Image::make($email_image->getRealPath())->resize(null, 100, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
}
// This requires a string instead of an object, so we use ($string)
Storage::disk('public')->put($email_file_name, (string) $email_upload->encode());
// Remove Current image if exists
if (($setting->email_logo) && (file_exists($email_file_name))) {
Storage::disk('public')->delete($email_file_name);
}
} elseif ('1' == $request->input('clear_email_logo')) {
if ('1' == $request->input('clear_email_logo')) {
Storage::disk('public')->delete($setting->email_logo);
$setting->email_logo = null;
// If they are uploading an image, validate it and upload it
}
// If the user wants to clear the label logo...
if ($request->hasFile('label_logo')) {
$image = $request->file('label_logo');
$ext = $image->getClientOriginalExtension();
$setting->label_logo = $label_file_name = 'label_logo.' . $ext;
$setting = $request->handleImages($setting,600,'label_logo','', 'label_logo');
if ('svg' != $image->getClientOriginalExtension()) {
$upload = Image::make($image->getRealPath())->resize(null, 100, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
}
// This requires a string instead of an object, so we use ($string)
Storage::disk('public')->put($label_file_name, (string) $upload->encode());
// Remove Current image if exists
if (($setting->label_logo) && (file_exists($label_file_name))) {
Storage::disk('public')->delete($label_file_name);
}
} elseif ('1' == $request->input('clear_label_logo')) {
if ('1' == $request->input('clear_label_logo')) {
Storage::disk('public')->delete($setting->label_logo);
$setting->label_logo = null;
// If they are uploading an image, validate it and upload it
}
// 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 (('ico' != $favicon_image->getClientOriginalExtension()) && ('svg' != $favicon_image->getClientOriginalExtension())) {
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();
@ -491,11 +458,6 @@ class SettingsController extends Controller
}
// Remove Current image if exists
if (($setting->favicon) && (file_exists($favicon_file_name))) {
Storage::disk('public')->delete($favicon_file_name);