Image handling reworked, new image formats added (#13900)

* Image handling reworked, new image formats added

* Updated messages.po

* The dot is now part of the file extension

* Added WebP in install documentation

* Handle unhandled mime types

* Fixed animated picture detected
This commit is contained in:
Michael Vogel 2024-02-17 07:45:41 +01:00 committed by GitHub
parent 1ea8a4042d
commit 14e5b06029
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 541 additions and 386 deletions

View file

@ -842,7 +842,6 @@ class Contact
return false;
}
$file_suffix = 'jpg';
$url = DI::baseUrl() . '/profile/' . $user['nickname'];
$fields = [
@ -875,17 +874,11 @@ class Contact
$fields['avatar-date'] = DateTimeFormat::utcNow();
}
// Creating the path to the avatar, beginning with the file suffix
$types = Images::supportedTypes();
if (isset($types[$avatar['type']])) {
$file_suffix = $types[$avatar['type']];
}
// We are adding a timestamp value so that other systems won't use cached content
$timestamp = strtotime($fields['avatar-date']);
$prefix = DI::baseUrl() . '/photo/' . $avatar['resource-id'] . '-';
$suffix = '.' . $file_suffix . '?ts=' . $timestamp;
$suffix = Images::getExtensionByMimeType($avatar['type']) . '?ts=' . $timestamp;
$fields['photo'] = $prefix . '4' . $suffix;
$fields['thumb'] = $prefix . '5' . $suffix;
@ -2313,8 +2306,8 @@ class Contact
$fetchResult = HTTPSignature::fetchRaw($avatar, 0, [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE]]);
$img_str = $fetchResult->getBodyString();
if (!empty($img_str)) {
$image = new Image($img_str, Images::getMimeTypeByData($img_str));
if ($fetchResult->isSuccess() && !empty($img_str)) {
$image = new Image($img_str, $fetchResult->getContentType(), $avatar);
if ($image->isValid()) {
$update_fields['blurhash'] = $image->getBlurHash();
} else {