Elgg  Version 3.0
default.php
Go to the documentation of this file.
1 <?php
16 $entity = elgg_extract('entity', $vars);
17 if (!$entity instanceof ElggEntity) {
18  return;
19 }
20 
22 // Get size
23 $size = elgg_extract('size', $vars, 'medium');
24 if (!array_key_exists($size, $icon_sizes)) {
25  $size = "medium";
26 }
27 $vars['size'] = $size;
28 
29 $class = elgg_extract('img_class', $vars, '');
30 
31 $title = htmlspecialchars($entity->getDisplayName(), ENT_QUOTES, 'UTF-8', false);
32 
33 $url = false;
34 if (elgg_extract('use_link', $vars, true)) {
35  $url = elgg_extract('href', $vars, $entity->getURL());
36 }
37 
38 if (!isset($vars['width'])) {
39  $vars['width'] = $size != 'master' ? $icon_sizes[$size]['w'] : null;
40 }
41 if (!isset($vars['height'])) {
42  $vars['height'] = $size != 'master' ? $icon_sizes[$size]['h'] : null;
43 }
44 
46  'src' => $entity->getIconURL($size),
47  'alt' => $title,
48 ];
49 
50 if (!empty($class)) {
51  $img_params['class'] = $class;
52 }
53 
54 if (!empty($vars['width'])) {
55  $img_params['width'] = elgg_extract('width', $vars);
56 }
57 
58 if (!empty($vars['height'])) {
59  $img_params['height'] = elgg_extract('height', $vars);
60 }
61 
62 $img = elgg_view('output/img', $img_params);
63 if (empty($img)) {
64  return;
65 }
66 
67 if ($url) {
68  $params = [
69  'href' => $url,
70  'text' => $img,
71  'is_trusted' => true,
72  ];
73  $class = elgg_extract('link_class', $vars, '');
74  if ($class) {
75  $params['class'] = $class;
76  }
77 
78  echo elgg_view('output/url', $params);
79 } else {
80  echo $img;
81 }
if(elgg_extract('use_link', $vars, true)) if(!isset($vars['width'])) if(!isset($vars['height'])) $img_params
Definition: default.php:45
elgg_get_icon_sizes($entity_type=null, $entity_subtype=null, $type= 'icon')
Returns a configuration array of icon sizes.
$class
Definition: default.php:29
if(elgg_extract('use_link', $vars, true)) if(!isset($vars['width'])) if(!isset($vars['height'])) if(!empty($class)) if(!empty($vars['width'])) if(!empty($vars['height'])) $img
Definition: default.php:62
elgg echo
Translates a string.
Definition: languages.js:43
$url
Definition: default.php:33
if(!array_key_exists($size, $icon_sizes)) $vars['size']
Definition: default.php:27
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1131
if(!$entity instanceof ElggEntity) $icon_sizes
Definition: default.php:21
$size
Definition: default.php:23
$entity
Definition: default.php:16
$title
Definition: default.php:31
$params
Definition: default.php:50
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:246