Improve wish image and favicon generation

This commit is contained in:
grandeljay 2022-06-16 15:11:33 +02:00
parent 29e37afa71
commit c34b9bd0aa
2 changed files with 5 additions and 5 deletions

View file

@ -35,7 +35,7 @@ switch ($_SERVER['REQUEST_METHOD']) {
if (isset($info->url) && $info->url) { if (isset($info->url) && $info->url) {
$code = URL::getResponseCode($info->url); $code = URL::getResponseCode($info->url);
if (200 !== $code) { if ($code < 200 || $code >= 400) {
$info->url = $url; $info->url = $url;
} }
} }
@ -87,7 +87,7 @@ switch ($_SERVER['REQUEST_METHOD']) {
if (!empty($info->image)) { if (!empty($info->image)) {
$codeImage = URL::getResponseCode($info->image); $codeImage = URL::getResponseCode($info->image);
if (200 === $codeImage) { if ($codeImage >= 200 && $codeImage < 400) {
$wish_image = '"' . $info->image . '"'; $wish_image = '"' . $info->image . '"';
} }
} }
@ -156,7 +156,7 @@ switch ($_SERVER['REQUEST_METHOD']) {
if (!empty($info->image)) { if (!empty($info->image)) {
$codeImage = URL::getResponseCode($info->image); $codeImage = URL::getResponseCode($info->image);
if (200 === $codeImage) { if ($codeImage >= 200 && $codeImage < 400) {
$wish_image = '"' . $info->image . '"'; $wish_image = '"' . $info->image . '"';
} }
} }

View file

@ -101,13 +101,13 @@ class Embed extends Cache
curl_close($ch); curl_close($ch);
$info->favicon = $favicon && 200 === $code ? 'data:image/x-icon;base64,' . base64_encode($favicon) : ''; $info->favicon = $favicon && ($code >= 200 && $code < 400) ? 'data:image/x-icon;base64,' . base64_encode($favicon) : '';
} }
/** URL */ /** URL */
$codeURL = \wishthis\URL::getResponseCode($info->url); $codeURL = \wishthis\URL::getResponseCode($info->url);
if (200 !== $codeURL) { if ($codeURL < 200 || $codeURL >= 400) {
$generateCache = false; $generateCache = false;
} }
} }