ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
custom_icon.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
33function custom_icon()
34{
35 global $DIC;
36 $f = $DIC->ui()->factory();
37 $renderer = $DIC->ui()->renderer();
38
39 $buffer = array();
40
41 $path = './assets/ui-examples/images/Icon/my_custom_icon.svg';
42 $ico = $f->symbol()->icon()->custom($path, 'Example');
43
44 $buffer[] = $renderer->render($ico)
45 . ' Small Custom Icon';
46
47 $buffer[] = $renderer->render($ico->withSize('medium'))
48 . ' Medium Custom Icon';
49
50 $buffer[] = $renderer->render($ico->withSize('large'))
51 . ' Large Custom Icon';
52
53
54 //Note that the svg needs to contain strictly valid xml to work with abbreviations.
55 //Some exports e.g. form illustrator seem to be not properly formatted by default.
56 $path = './assets/images/standard/icon_fold.svg';
57 $ico = $f->symbol()->icon()->custom($path, 'Example')
58 ->withAbbreviation('FD');
59
60 $buffer[] = $renderer->render($ico)
61 . ' Small Custom Icon with Abbreviation';
62
63 $buffer[] = $renderer->render($ico->withSize('medium'))
64 . ' Medium Custom Icon with Abbreviation';
65
66 $buffer[] = $renderer->render($ico->withSize('large'))
67 . ' Large Custom Icon with Abbreviation';
68
69
70 return implode('<br><br>', $buffer);
71}
$renderer
$path
Definition: ltiservices.php:30
global $DIC
Definition: shib_login.php:26