mirror of
https://github.com/snipe/snipe-it.git
synced 2026-02-05 06:25:24 +00:00
Allow multiple upload fields and add logo option to labels (#6736)
* Change upload js to work with multiple upload elements on a single page * Change uploadFile in upload modal and form partial * Change uploadFile to js-uploadFile to avoid potential issues in the future * Remove duplicate style attribute causing webpack to fail * Missed a css class in rename to js- prefix * - Move logo uploads to partial for eaiser usage - Add label logo - Add css classes to label elements - Change label prefix text (M: S: ...) to css::before content for easy removal in config * Add more css classes to labels * Allow unescaped " (quot) in css ouput * Add max size param to partial, set defaults for allowedType and size
This commit is contained in:
@ -412,13 +412,13 @@ class SettingsController extends Controller
|
||||
$setting->brand = 1;
|
||||
|
||||
// If they are uploading an image, validate it and upload it
|
||||
} elseif ($request->hasFile('image')) {
|
||||
$image = $request->file('image');
|
||||
} elseif ($request->hasFile('logo')) {
|
||||
$image = $request->file('logo');
|
||||
$ext = $image->getClientOriginalExtension();
|
||||
$setting->logo = $file_name = 'logo.' . $ext;
|
||||
|
||||
if ('svg' != $image->getClientOriginalExtension()) {
|
||||
$upload = Image::make($image->getRealPath())->resize(null, 150, function($constraint) {
|
||||
$upload = Image::make($image->getRealPath())->resize(null, 150, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
});
|
||||
@ -438,14 +438,14 @@ class SettingsController extends Controller
|
||||
Storage::disk('public')->delete($setting->email_logo);
|
||||
$setting->email_logo = null;
|
||||
|
||||
// If they are uploading an image, validate it and upload it
|
||||
// If they are uploading an image, validate it and upload it
|
||||
} elseif ($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;
|
||||
|
||||
if ('svg' != $email_image->getClientOriginalExtension()) {
|
||||
$email_upload = Image::make($email_image->getRealPath())->resize(null, 100, function($constraint) {
|
||||
$email_upload = Image::make($email_image->getRealPath())->resize(null, 100, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
});
|
||||
@ -460,21 +460,46 @@ class SettingsController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
// If the user wants to clear the 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
|
||||
} elseif ($request->hasFile('label_logo')) {
|
||||
$image = $request->file('label_logo');
|
||||
$ext = $image->getClientOriginalExtension();
|
||||
$setting->label_logo = $label_file_name = 'label_logo.' . $ext;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// If the user wants to clear the favicon...
|
||||
if ('1' == $request->input('clear_favicon')) {
|
||||
Storage::disk('public')->delete($setting->clear_favicon);
|
||||
$setting->favicon = null;
|
||||
|
||||
// If they are uploading an image, validate it and upload it
|
||||
// If they are uploading an image, validate it and upload it
|
||||
} elseif ($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())) {
|
||||
$favicon_upload = Image::make($favicon_image->getRealPath())->resize(null, 36, function($constraint) {
|
||||
$favicon_upload = Image::make($favicon_image->getRealPath())->resize(null, 36, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user