54 if (empty($image_url)) {
58 $image_url = htmlspecialchars_decode($image_url);
69 if (stripos($image_url,
$site->getURL()) === 0) {
71 $cookie_config = $this->config->getCookieConfig();
74 $cookie_config[
'session'][
'name'] => $this->session->getID(),
77 $domain = $cookie_config[
'session'][
'domain'] ?:
$site->getDomain();
79 $cookiejar = CookieJar::fromArray($cookies,
$domain);
80 $options[RequestOptions::COOKIES] = $cookiejar;
85 }
catch (TransferException $e) {
95 'data' =>
$response->getBody()->getContents(),
96 'content-type' =>
$response->getHeaderLine(
'content-type') ?:
'application/octet-stream',
97 'name' => basename($image_url),
113 $cache = $this->cache->load(self::CACHE_PREFIX .
md5($image_url));
115 return is_array($cache) ? $cache : [];
127 return $this->cache->save(self::CACHE_PREFIX .
md5($image_url), $data);
Exception thrown if an argument is not of the expected type.
getImage(string $image_url)
Get an image.
$config
Advanced site settings, debugging section.
if($who_can_change_language=== 'nobody') elseif($who_can_change_language=== 'admin_only'&&!elgg_is_admin_logged_in()) $options
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.
if(isset($_COOKIE['elggperm'])) $session
elgg_get_http_client(array $options=[])
Returns a Guzzle HTTP client.
elgg_normalize_url(string $url)
__construct(protected Config $config, protected SystemCache $cache, protected\ElggSession $session)
Constructor.