add svg images support, fix mime validation

This commit is contained in:
ghost 2023-05-08 13:12:16 +03:00
parent e9d5137dfe
commit 84dcecf50b
2 changed files with 8 additions and 2 deletions

View File

@ -292,6 +292,8 @@ try {
if ($hostImageBanned) { if ($hostImageBanned) {
$hostImagesBanned += $db->updateHostImageTimeBanned($queueHostImage->hostImageId, time()); $hostImagesBanned += $db->updateHostImageTimeBanned($queueHostImage->hostImageId, time());
continue;
} }
// Convert remote image data to base64 string // Convert remote image data to base64 string
@ -319,7 +321,7 @@ try {
continue; continue;
} }
$hostImageData = 'data:image/' . $hostImageExtension . ';base64,' . $hostImageBase64; $hostImageData = 'data:image/' . str_replace(['svg'], ['svg+xml'], $hostImageExtension) . ';base64,' . $hostImageBase64;
} else { } else {
@ -380,6 +382,8 @@ try {
if ($hostPageBanned) { if ($hostPageBanned) {
$hostPagesBanned += $db->updateHostPageTimeBanned($queueHostPage->hostPageId, time()); $hostPagesBanned += $db->updateHostPageTimeBanned($queueHostPage->hostPageId, time());
continue;
} }
// Skip page processing without returned data // Skip page processing without returned data

View File

@ -382,6 +382,8 @@ if (!empty($q)) {
if ($hostImageBanned) { if ($hostImageBanned) {
$hostImagesBanned += $db->updateHostImageTimeBanned($hostImage->hostImageId, time()); $hostImagesBanned += $db->updateHostImageTimeBanned($hostImage->hostImageId, time());
continue;
} }
// Skip image processing without returned content // Skip image processing without returned content
@ -407,7 +409,7 @@ if (!empty($q)) {
continue; continue;
} }
$hostImageURLencoded = 'data:image/' . $hostImageExtension . ';base64,' . $hostImageBase64; $hostImageURLencoded = 'data:image/' . str_replace(['svg'], ['svg+xml'], $hostImageExtension) . ';base64,' . $hostImageBase64;
// Save image content on data settings enabled // Save image content on data settings enabled
$db->updateHostImage($hostImage->hostImageId, $db->updateHostImage($hostImage->hostImageId,