* @param integer $cid contact id
* @param string $size One of the Proxy::SIZE_* constants
* @param string $updated Contact update date
+ * @param bool $static If "true" a parameter is added to convert the header to a static one
* @return string avatar link
*/
- public static function getAvatarUrlForId(int $cid, string $size = '', string $updated = '', string $guid = ''): string
+ public static function getAvatarUrlForId(int $cid, string $size = '', string $updated = '', string $guid = '', bool $static = false): string
{
// We have to fetch the "updated" variable when it wasn't provided
// The parameter can be provided to improve performance
$url .= Proxy::PIXEL_LARGE . '/';
break;
}
- return $url . ($guid ?: $cid) . ($updated ? '?ts=' . strtotime($updated) : '');
+ $query_params = [];
+ if ($updated) {
+ $query_params['ts'] = strtotime($updated);
+ }
+ if ($static) {
+ $query_params['static'] = true;
+ }
+
+ return $url . ($guid ?: $cid) . (!empty($query_params) ? '?' . http_build_query($query_params) : '');
}
/**
* @param integer $cid contact id
* @param string $size One of the Proxy::SIZE_* constants
* @param string $updated Contact update date
+ * @param bool $static If "true" a parameter is added to convert the header to a static one
* @return string header link
*/
- public static function getHeaderUrlForId(int $cid, string $size = '', string $updated = '', string $guid = ''): string
+ public static function getHeaderUrlForId(int $cid, string $size = '', string $updated = '', string $guid = '', bool $static = false): string
{
// We have to fetch the "updated" variable when it wasn't provided
// The parameter can be provided to improve performance
break;
}
- return $url . ($guid ?: $cid) . ($updated ? '?ts=' . strtotime($updated) : '');
+ $query_params = [];
+ if ($updated) {
+ $query_params['ts'] = strtotime($updated);
+ }
+ if ($static) {
+ $query_params['static'] = true;
+ }
+
+ return $url . ($guid ?: $cid) . (!empty($query_params) ? '?' . http_build_query($query_params) : '');
}
/**
use Friendica\BaseModule;
use Friendica\Core\System;
-use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\APContact;
use Friendica\Model\User;
throw new HTTPException\InternalServerErrorException($error);
}
+ if (!empty($request['static'])) {
+ $img = new Image($imgdata, $photo['type']);
+ $img->toStatic();
+ $imgdata = $img->asString();
+ }
+
// if customsize is set and image is not a gif, resize it
if ($photo['type'] !== 'image/gif' && $customsize > 0 && $customsize <= Proxy::PIXEL_THUMB && $square_resize) {
$img = new Image($imgdata, $photo['type']);
$this->note = BBCode::convertForUriId($account['uri-id'], $account['about'], BBCode::EXTERNAL);
$this->url = $account['url'];
$this->avatar = Contact::getAvatarUrlForId($account['id'] ?? 0 ?: $account['pid'], Proxy::SIZE_SMALL, $account['updated'], $account['guid'] ?? '');
- $this->avatar_static = $this->avatar;
+ $this->avatar_static = Contact::getAvatarUrlForId($account['id'] ?? 0 ?: $account['pid'], Proxy::SIZE_SMALL, $account['updated'], $account['guid'] ?? '', true);
$this->header = Contact::getHeaderUrlForId($account['id'] ?? 0 ?: $account['pid'], '', $account['updated'], $account['guid'] ?? '');
- $this->header_static = $this->header;
+ $this->header_static = Contact::getHeaderUrlForId($account['id'] ?? 0 ?: $account['pid'], '', $account['updated'], $account['guid'] ?? '', true);
$this->followers_count = $account['ap-followers_count'] ?? $account['diaspora-interacted_count'] ?? 0;
$this->following_count = $account['ap-following_count'] ?? $account['diaspora-interacting_count'] ?? 0;
$this->statuses_count = $account['ap-statuses_count'] ?? $account['diaspora-post_count'] ?? 0;
*/
public function __construct(string $data, string $type = null)
{
- $this->imagick = class_exists('Imagick');
+ $this->imagick = class_exists('Imagick') && !class_exists('GDImage');
$this->types = Images::supportedTypes();
if (!array_key_exists($type, $this->types)) {
$type = 'image/jpeg';
$row = [];
for ($x = 0; $x < $width; ++$x) {
$index = imagecolorat($this->image, $x, $y);
- $colors = imagecolorsforindex($this->image, $index);
+ $colors = @imagecolorsforindex($this->image, $index);
$row[] = [$colors['red'], $colors['green'], $colors['blue']];
}