Elgg  Version master
header_image.php
Go to the documentation of this file.
1 <?php
6 $header_url = elgg_extract('header_url', $vars);
7 if ($header_url === false) {
8  // we do not want a header image
9  return;
10 }
11 
12 $entity = elgg_extract('entity', $vars);
13 $type = 'header';
14 $size = 'header';
15 
16 $class = ['elgg-header-image'];
17 
18 if (empty($header_url)) {
19  if (!$entity instanceof \ElggEntity || !$entity->hasIcon($size, $type)) {
20  return;
21  }
22 
23  $class[] = "elgg-header-image-{$entity->type}-{$entity->subtype}";
24 
25  $header_url = $entity->getIconUrl(['type' => $type, 'size' => $size]);
26 }
27 
28 echo elgg_format_element('div', [
29  'class' => $class,
30 ], elgg_format_element('div', ['style' => "background-image: url({$header_url})"]));
if($header_url===false) $entity
$size
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:254
$header_url
Elgg page header image.
Definition: header_image.php:6
$vars
Definition: theme.php:5
$type
$class
elgg_format_element(string $tag_name, array $attributes=[], string $text= '', array $options=[])
Format an HTML element.
Definition: output.php:145