mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-10 18:02:55 +00:00
perf: 图片容错处理
This commit is contained in:
parent
520d2a0e20
commit
29bc009c07
@ -223,6 +223,19 @@ class Handler extends ExceptionHandler
|
||||
} catch (\ImagickException) { }
|
||||
}
|
||||
|
||||
// 容错处理
|
||||
$patternFault = '/^(images\/.*\.(png|jpg|jpeg))\/crop\/([^\/]+)$/';
|
||||
$matchesFault = null;
|
||||
if (preg_match($patternFault, $path, $matchesFault)) {
|
||||
$file = public_path($matchesFault[1]);
|
||||
if (!file_exists($file)) {
|
||||
$file = public_path('images/other/imgerr.jpg');
|
||||
}
|
||||
if (file_exists($file)) {
|
||||
return response()->file($file);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,6 +69,6 @@ Route::middleware(['webapi'])->group(function () {
|
||||
Route::any('/{method}', IndexController::class);
|
||||
Route::any('/{method}/{action}', IndexController::class);
|
||||
Route::any('/{method}/{action}/{child}', IndexController::class);
|
||||
Route::any('/{method}/{action}/{child}/{n}', IndexController::class)->where('method', '^(?!uploads).*');
|
||||
Route::any('/{method}/{action}/{child}/{n}/{c}', IndexController::class)->where('method', '^(?!uploads).*');
|
||||
Route::any('/{method}/{action}/{child}/{n}', IndexController::class)->where('method', '^(?!(uploads|images)).*');
|
||||
Route::any('/{method}/{action}/{child}/{n}/{c}', IndexController::class)->where('method', '^(?!(uploads|images)).*');
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user