diff --git a/app/common/service/WordpressSiteService.php b/app/common/service/WordpressSiteService.php index 780eedb..664c67b 100644 --- a/app/common/service/WordpressSiteService.php +++ b/app/common/service/WordpressSiteService.php @@ -577,12 +577,15 @@ class WordpressSiteService ] ]); - $brand = json_decode($response->getBody(), true); + $responseBody = $response->getBody()->getContents(); + $brand = json_decode($responseBody, true); if (empty($brand) || !isset($brand['id'])) { Log::error('创建品牌失败,响应无效', [ 'brand_name' => $brand_name, - 'response' => $response->getBody()->getContents(), + 'slug' => $slug, + 'response' => $responseBody, + 'status_code' => $response->getStatusCode(), ]); return 0; } @@ -592,6 +595,7 @@ class WordpressSiteService } catch (\Exception $e) { Log::error('创建品牌失败', [ 'brand_name' => $brand_name, + 'slug' => $slug, 'error' => $e->getMessage(), ]); return 0; @@ -803,7 +807,8 @@ class WordpressSiteService */ public function uploadImageToWp(string $domain,$api_user, $api_secret, string $imageUrl = "fdesk_test/usedcar_crawl/20251125/ff847a6a2b3114b4c2c230455b74cd2e.jpg"): array { - $process = 'image/resize,w_800/quality,Q_50/format,webp'; + // 使用原始图片格式,不做webp转换,避免"File Modified"错误 + $process = 'image/resize,w_800/quality,Q_50'; try { $processedUrl = (new OssService)->generatePrivateUrlResize($imageUrl,3600,$process); @@ -821,8 +826,9 @@ class WordpressSiteService $pathInfo = pathinfo(parse_url($imageUrl, PHP_URL_PATH)); $extension = strtolower($pathInfo['extension'] ?? 'jpg'); - // 根据处理后的格式确定文件名和 Content-Type - if (strpos($processedUrl, 'webp') !== false || strpos($process, 'webp') !== false) { + // 确定文件名和 Content-Type(使用原始格式) + $filename = ($pathInfo['filename'] ?? 'image') . '.' . $extension; + $contentType = 'image/' . ($extension === 'jpg' ? 'jpeg' : $extension); $filename = ($pathInfo['filename'] ?? 'image') . '.webp'; $contentType = 'image/webp'; } else {