69 if (empty($image_url)) {
73 $image_url = htmlspecialchars_decode($image_url);
84 if (stripos($image_url,
$site->getURL()) === 0) {
86 $cookie_config = $this->config->getCookieConfig();
89 $cookie_config[
'session'][
'name'] => $this->session->getID(),
92 $domain = $cookie_config[
'session'][
'domain'] ?:
$site->getDomain();
94 $cookiejar = CookieJar::fromArray($cookies,
$domain);
95 $options[RequestOptions::COOKIES] = $cookiejar;
100 }
catch (TransferException $e) {
110 'data' =>
$response->getBody()->getContents(),
111 'content-type' =>
$response->getHeaderLine(
'content-type') ?:
'application/octet-stream',
112 'name' => basename($image_url),
128 $cache = $this->cache->load(self::CACHE_PREFIX .
md5($image_url));
142 return $this->cache->save(self::CACHE_PREFIX .
md5($image_url), $data);
Exception thrown if an argument is not of the expected type.
__construct(Config $config, SystemCache $cache,\ElggSession $session)
Constructor.
getImage(string $image_url)
Get an image.
if(!$entity instanceof\ElggUser) $data
loadFromCache(string $image_url)
Load an image url from cache.
Fetch external images server side.
saveToCache(string $image_url, array $data)
Save image data in system cache for easy reuse.
elgg_get_site_entity()
Get the current site entity.
elgg_get_http_client(array $options=[])
Returns a Guzzle HTTP client.
elgg_normalize_url(string $url)