mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-09 20:52:56 +01:00
Check for large logo image files
This commit is contained in:
parent
0732f068ff
commit
1b099d09cc
@ -1,7 +1,6 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use Auth;
|
||||
use Event;
|
||||
use File;
|
||||
use Image;
|
||||
use Input;
|
||||
@ -227,6 +226,17 @@ class AccountController extends BaseController
|
||||
|
||||
private function showCompanyDetails()
|
||||
{
|
||||
// check that logo is less than the max file size
|
||||
$account = Auth::user()->account;
|
||||
if ($account->hasLogo()) {
|
||||
$filename = $account->getLogoPath();
|
||||
$bytes = File::size($filename);
|
||||
if ($bytes > MAX_LOGO_FILE_SIZE * 1000) {
|
||||
$bytes /= 1000;
|
||||
Session::flash('warning', trans('texts.logo_too_large', ['size' => round($bytes) . 'KB']));
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'account' => Account::with('users')->findOrFail(Auth::user()->account_id),
|
||||
'countries' => Cache::get('countries'),
|
||||
@ -842,7 +852,7 @@ class AccountController extends BaseController
|
||||
{
|
||||
$rules = array(
|
||||
'name' => 'required',
|
||||
'logo' => 'sometimes|max:200|mimes:jpeg,gif,png',
|
||||
'logo' => 'sometimes|max:' . MAX_LOGO_FILE_SIZE . '|mimes:jpeg,gif,png',
|
||||
);
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
@ -905,7 +915,7 @@ class AccountController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
Event::fire(new UserSettingsChanged());
|
||||
event(new UserSettingsChanged());
|
||||
|
||||
Session::flash('message', trans('texts.updated_settings'));
|
||||
return Redirect::to('settings/' . ACCOUNT_COMPANY_DETAILS);
|
||||
@ -940,7 +950,7 @@ class AccountController extends BaseController
|
||||
|
||||
$user->save();
|
||||
|
||||
Event::fire(new UserSettingsChanged());
|
||||
event(new UserSettingsChanged());
|
||||
Session::flash('message', trans('texts.updated_settings'));
|
||||
return Redirect::to('settings/' . ACCOUNT_USER_DETAILS);
|
||||
}
|
||||
@ -957,7 +967,7 @@ class AccountController extends BaseController
|
||||
$account->military_time = Input::get('military_time') ? true : false;
|
||||
$account->save();
|
||||
|
||||
Event::fire(new UserSettingsChanged());
|
||||
event(new UserSettingsChanged());
|
||||
|
||||
Session::flash('message', trans('texts.updated_settings'));
|
||||
return Redirect::to('settings/' . ACCOUNT_LOCALIZATION);
|
||||
|
@ -334,6 +334,7 @@ if (!defined('CONTACT_EMAIL')) {
|
||||
define('MAX_NUM_USERS', 20);
|
||||
define('MAX_SUBDOMAIN_LENGTH', 30);
|
||||
define('MAX_IFRAME_URL_LENGTH', 250);
|
||||
define('MAX_LOGO_FILE_SIZE', 200); // KB
|
||||
define('DEFAULT_FONT_SIZE', 9);
|
||||
define('DEFAULT_SEND_RECURRING_HOUR', 8);
|
||||
|
||||
|
@ -918,4 +918,5 @@ return array(
|
||||
'country' => 'Country',
|
||||
'include' => 'Include',
|
||||
|
||||
'logo_too_large' => 'Your logo is :size, for better performance we suggest uploading an image file less than 200KB',
|
||||
);
|
||||
|
@ -22,7 +22,7 @@
|
||||
->addClass('warn-on-exit')
|
||||
->autocomplete('on')
|
||||
->rules([
|
||||
'name' => 'required'
|
||||
'name' => 'required'
|
||||
]) !!}
|
||||
|
||||
{{ Former::populate($account) }}
|
||||
@ -37,24 +37,29 @@
|
||||
<h3 class="panel-title">{!! trans('texts.details') !!}</h3>
|
||||
</div>
|
||||
<div class="panel-body form-padding-right">
|
||||
|
||||
{!! Former::text('name') !!}
|
||||
|
||||
{!! Former::text('name') !!}
|
||||
{!! Former::text('id_number') !!}
|
||||
{!! Former::text('vat_number') !!}
|
||||
{!! Former::text('work_email') !!}
|
||||
{!! Former::text('work_phone') !!}
|
||||
{!! Former::text('work_email') !!}
|
||||
{!! Former::text('work_phone') !!}
|
||||
{!! Former::file('logo')->max(2, 'MB')->accept('image')->inlineHelp(trans('texts.logo_help')) !!}
|
||||
|
||||
|
||||
@if ($account->hasLogo())
|
||||
<center>
|
||||
{!! HTML::image($account->getLogoPath().'?no_cache='.time(), 'Logo', ['width' => 200]) !!}
|
||||
<a href="#" onclick="deleteLogo()">{{ trans('texts.remove_logo') }}</a>
|
||||
</center><br/>
|
||||
@endif
|
||||
@if ($account->hasLogo())
|
||||
<div class="form-group">
|
||||
<div class="col-lg-4 col-sm-4"></div>
|
||||
<div class="col-lg-8 col-sm-8">
|
||||
<a href="/{{ $account->getLogoPath().'?no_cache='.time() }}" target="_blank">
|
||||
{!! HTML::image($account->getLogoPath().'?no_cache='.time(), 'Logo', ['width' => 200]) !!}
|
||||
</a>
|
||||
<a href="#" onclick="deleteLogo()">{{ trans('texts.remove_logo') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{!! Former::select('size_id')->addOption('','')->fromQuery($sizes, 'name', 'id') !!}
|
||||
{!! Former::select('industry_id')->addOption('','')->fromQuery($industries, 'name', 'id') !!}
|
||||
{!! Former::select('size_id')->addOption('','')->fromQuery($sizes, 'name', 'id') !!}
|
||||
{!! Former::select('industry_id')->addOption('','')->fromQuery($industries, 'name', 'id') !!}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user