Detect errors from resize-img using substr_count()

This commit is contained in:
Sheldon Lee 2023-11-18 16:42:33 +08:00
parent 22a70bd4de
commit c5b4dda950

View File

@ -86,8 +86,9 @@ function create_thumbnail(string $category, string $file): string | null {
log_print("generating thumbnail for $original_file"); log_print("generating thumbnail for $original_file");
$output = shell_exec(THUMBNAIL_SCRIPT." '$original_file' '$thumbnail_file' 2>&1"); $output = shell_exec(THUMBNAIL_SCRIPT." '$original_file' '$thumbnail_file' 2>&1");
if ($output) log_print($output); if ($output) log_print($output);
if ($output === false) { if (substr_count(strtolower((string) $output), "error")) {
log_error("Thumbnail failed"); log_error("Thumbnail failed");
log_print(ROOT_URL.IMG_DIR.$path);
return ROOT_URL.IMG_DIR.$path; return ROOT_URL.IMG_DIR.$path;
} }