optimized png for slider group category

pull/44/head
A1Gard 6 months ago
parent 2325536a26
commit fb4ba85c61

@ -62,10 +62,14 @@ class CategoryController extends XController
if ($request->has('image')) { if ($request->has('image')) {
$category->image = $this->storeFile('image', $category, 'categories'); $category->image = $this->storeFile('image', $category, 'categories');
$key = 'image'; $key = 'image';
$format = $request->file($key)->guessExtension();
if (strtolower($format) == 'png'){
$format = 'webp';
}
$i = Image::load($request->file($key)->getPathname()) $i = Image::load($request->file($key)->getPathname())
->optimize() ->optimize()
// ->nonQueued() // ->nonQueued()
->format($request->file($key)->extension()); ->format($format);
if (getSetting('watermark2')) { if (getSetting('watermark2')) {
$i->watermark(public_path('upload/images/logo.png'), $i->watermark(public_path('upload/images/logo.png'),
AlignPosition::BottomLeft, 5, 5, Unit::Percent, AlignPosition::BottomLeft, 5, 5, Unit::Percent,
@ -78,10 +82,14 @@ class CategoryController extends XController
if ($request->has('bg')) { if ($request->has('bg')) {
$category->bg = $this->storeFile('bg', $category, 'categories'); $category->bg = $this->storeFile('bg', $category, 'categories');
$key = 'bg'; $key = 'bg';
$format = $request->file($key)->guessExtension();
if (strtolower($format) == 'png'){
$format = 'webp';
}
$i = Image::load($request->file($key)->getPathname()) $i = Image::load($request->file($key)->getPathname())
->optimize() ->optimize()
// ->nonQueued() // ->nonQueued()
->format($request->file($key)->extension()); ->format($format);
if (getSetting('watermark2')) { if (getSetting('watermark2')) {
$i->watermark(public_path('upload/images/logo.png'), $i->watermark(public_path('upload/images/logo.png'),
AlignPosition::BottomLeft, 5, 5, Unit::Percent, AlignPosition::BottomLeft, 5, 5, Unit::Percent,

@ -61,10 +61,14 @@ class GroupController extends XController
if ($request->has('image')){ if ($request->has('image')){
$group->image = $this->storeFile('image',$group, 'groups'); $group->image = $this->storeFile('image',$group, 'groups');
$key = 'image'; $key = 'image';
$format = $request->file($key)->guessExtension();
if (strtolower($format) == 'png'){
$format = 'webp';
}
$i = Image::load($request->file($key)->getPathname()) $i = Image::load($request->file($key)->getPathname())
->optimize() ->optimize()
// ->nonQueued() // ->nonQueued()
->format($request->file($key)->extension()); ->format($format);
if (getSetting('watermark2')) { if (getSetting('watermark2')) {
$i->watermark(public_path('upload/images/logo.png'), $i->watermark(public_path('upload/images/logo.png'),
AlignPosition::BottomLeft, 5, 5, Unit::Percent, AlignPosition::BottomLeft, 5, 5, Unit::Percent,
@ -77,10 +81,14 @@ class GroupController extends XController
if ($request->has('bg')){ if ($request->has('bg')){
$group->bg = $this->storeFile('bg',$group, 'groups'); $group->bg = $this->storeFile('bg',$group, 'groups');
$key = 'bg'; $key = 'bg';
$format = $request->file($key)->guessExtension();
if (strtolower($format) == 'png'){
$format = 'webp';
}
$i = Image::load($request->file($key)->getPathname()) $i = Image::load($request->file($key)->getPathname())
->optimize() ->optimize()
// ->nonQueued() // ->nonQueued()
->format($request->file($key)->extension()); ->format($format);
if (getSetting('watermark2')) { if (getSetting('watermark2')) {
$i->watermark(public_path('upload/images/logo.png'), $i->watermark(public_path('upload/images/logo.png'),
AlignPosition::BottomLeft, 5, 5, Unit::Percent, AlignPosition::BottomLeft, 5, 5, Unit::Percent,

@ -61,12 +61,15 @@ class SliderController extends XController
$name = time() . '.' . request()->cover->getClientOriginalExtension(); $name = time() . '.' . request()->cover->getClientOriginalExtension();
$slider->image = $name; $slider->image = $name;
$request->file('cover')->storeAs('public/sliders', $name); $request->file('cover')->storeAs('public/sliders', $name);
$format = $request->file('cover')->guessExtension();
if (strtolower($format) == 'png'){
$format = 'webp';
}
$key = 'cover'; $key = 'cover';
$i = Image::load($request->file($key)->getPathname()) $i = Image::load($request->file($key)->getPathname())
->optimize() ->optimize()
// ->nonQueued() // ->nonQueued()
->format($request->file($key)->extension()); ->format($format);
if (getSetting('watermark2')) { if (getSetting('watermark2')) {
$i->watermark(public_path('upload/images/logo.png'), $i->watermark(public_path('upload/images/logo.png'),
AlignPosition::BottomLeft, 5, 5, Unit::Percent, AlignPosition::BottomLeft, 5, 5, Unit::Percent,

Loading…
Cancel
Save