return $fields;
}
+ /**
+ * Construct a photo array for a given image data string
+ *
+ * @param string $image_data Image data
+ * @param string $mimetype Image mime type. Is guessed by file name when empty.
+ *
+ * @return array
+ * @throws \Exception
+ */
+ public static function createPhotoForImageData(string $image_data, string $mimetype = ''): array
+ {
+ $fields = self::getFields();
+ $values = array_fill(0, count($fields), '');
+
+ $photo = array_combine($fields, $values);
+ $photo['data'] = $image_data;
+ $photo['type'] = $mimetype ?: Images::getMimeTypeByData($image_data);
+ $photo['cacheable'] = false;
+
+ return $photo;
+ }
+
/**
* Construct a photo array for a system resource image
*
* @return array
* @throws \Exception
*/
- public static function createPhotoForExternalResource(string $url, int $uid = 0, string $mimetype = '', string $blurhash = '', int $width = 0, int $height = 0): array
+ public static function createPhotoForExternalResource(string $url, int $uid = 0, string $mimetype = '', string $blurhash = null, int $width = null, int $height = null): array
{
if (empty($mimetype)) {
$mimetype = Images::guessTypeByExtension($url);
$micro = Contact::getDefaultAvatar($contact, Proxy::SIZE_MICRO);
}
- return [$image_url, $thumb, $micro];
+ $photo = DBA::selectFirst(
+ 'photo', ['blurhash'], ['uid' => $uid, 'contact-id' => $cid, 'scale' => 4, 'photo-type' => self::CONTACT_AVATAR]
+ );
+
+ return [$image_url, $thumb, $micro, $photo['blurhash']];
}
/**
logger::warning('profile banner upload with scale 3 (960) failed');
}
- logger::info('new profile banner upload ended');
+ logger::info('new profile banner upload ended', ['uid' => $uid, 'resource_id' => $resource_id, 'filename' => $filename]);
$condition = ["`photo-type` = ? AND `resource-id` != ? AND `uid` = ?", self::USER_BANNER, $resource_id, $uid];
self::update(['photo-type' => self::DEFAULT], $condition);