From 5f3dd6b45207050638e4b01e145707dcbcc84451 Mon Sep 17 00:00:00 2001 From: Guoqing Zou Date: Sun, 29 Sep 2024 14:57:55 +0000 Subject: [PATCH] fix: og img conflicts with img proxy --- src/Extend/ImageSize/FormatImgs.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Extend/ImageSize/FormatImgs.php b/src/Extend/ImageSize/FormatImgs.php index d006d99..745b196 100644 --- a/src/Extend/ImageSize/FormatImgs.php +++ b/src/Extend/ImageSize/FormatImgs.php @@ -108,7 +108,11 @@ private function processAttributes($url, $attributes) { private function processImageProxyAttributes($url, $attributes) { $newUrl = $this->getImageProxyURL($url); - $attributes['src'] = $newUrl; + /** + * hack: getImageProxyURL 生成的非 png / jpg 的 url 中没有 .jpg 的后缀,导致 seo 插件识别 og:image 生成有误,不想去改它正则,这里加一个 hack 骗过正则检测 + * @url https://github.com/v17development/flarum-seo/blob/2091f651cde88fccf4ddc49d97ed33cbad44200e/src/Listeners/PageListener.php + */ + $attributes['src'] = $newUrl.'?.jpg'; $attributes['url'] = $newUrl; $attributes['origsrc'] = $url; return $attributes;