ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
custom_icon.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
17 function custom_icon()
18 {
19  global $DIC;
20  $f = $DIC->ui()->factory();
21  $renderer = $DIC->ui()->renderer();
22 
23  $buffer = array();
24 
25  $path = './assets/ui-examples/images/Icon/my_custom_icon.svg';
26  $ico = $f->symbol()->icon()->custom($path, 'Example');
27 
28  $buffer[] = $renderer->render($ico)
29  . ' Small Custom Icon';
30 
31  $buffer[] = $renderer->render($ico->withSize('medium'))
32  . ' Medium Custom Icon';
33 
34  $buffer[] = $renderer->render($ico->withSize('large'))
35  . ' Large Custom Icon';
36 
37 
38  //Note that the svg needs to contain strictly valid xml to work with abbreviations.
39  //Some exports e.g. form illustrator seem to be not properly formatted by default.
40  $path = './assets/images/standard/icon_fold.svg';
41  $ico = $f->symbol()->icon()->custom($path, 'Example')
42  ->withAbbreviation('FD');
43 
44  $buffer[] = $renderer->render($ico)
45  . ' Small Custom Icon with Abbreviation';
46 
47  $buffer[] = $renderer->render($ico->withSize('medium'))
48  . ' Medium Custom Icon with Abbreviation';
49 
50  $buffer[] = $renderer->render($ico->withSize('large'))
51  . ' Large Custom Icon with Abbreviation';
52 
53 
54  return implode('<br><br>', $buffer);
55 }
$renderer
custom_icon()
description: > Example for rendering custom icons.
Definition: custom_icon.php:17
$path
Definition: ltiservices.php:30
global $DIC
Definition: shib_login.php:25