aboutsummaryrefslogtreecommitdiff
path: root/mod/lightpics/views/default/icon/object/image.php
blob: 9087fc3d8ef1982fd9eb4c1531bac4889411396b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
 * Image icon view
 *
 * @uses $vars['entity']     The entity the icon represents - uses getIconURL() method
 * @uses $vars['size']       tiny, small (default), large, master
 * @uses $vars['href']       Optional override for link
 * @uses $vars['img_class']  Optional CSS class added to img
 * @uses $vars['link_class'] Optional CSS class added to link
 * @uses $vars['title']      Optional title override
 *
 * @author Cash Costello
 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
 */

$entity = $vars['entity'];

$sizes = array('master', 'large', 'small', 'tiny');
// Get size
if (!in_array($vars['size'], $sizes)) {
	$vars['size'] = 'small';
}

if (!isset($vars['title'])) {
	$title = $entity->getTitle();
} else {
	$title = $vars['title'];
}

$url = isset($vars['href']) ? $vars['href'] : $entity->getURL();
if (isset($vars['href'])) {
	$url = $vars['href'];
}

$class = '';
if (isset($vars['img_class'])) {
	$class = $vars['img_class'];
}
$class = "elgg-photo $class";

$img_src = $entity->getIconURL($vars['size']);
$img_src = elgg_format_url($img_src);
$img = elgg_view('output/img', array(
	'src' => $img_src,
	'class' => $class,
	'title' => $title,
	'alt' => $title,
));

if ($url) {
	$params = array(
		'href' => $url,
		'text' => $img,
		'is_trusted' => true,
	);
	if (isset($vars['link_class'])) {
		$params['class'] = $vars['link_class'];
	}
	echo elgg_view('output/url', $params);
} else {
	echo $img;
}