19 declare(strict_types=1);
43 $tpl = $this->
getTemplate(
"tpl.image.html",
true,
true);
45 if (($sources = $component->getAdditionalHighResSources()) !== []) {
46 $component = $component->withAdditionalOnLoadCode(
47 fn(
string $id):
string =>
" 48 const imageElement = il.UI.image.getImageElement('$id'); 49 if (imageElement === null) { 50 throw new Error(`Image '$id' not found.`); 52 il.UI.image.loadHighResolutionSource( 54 {$this->getHighResSourceMapForJs($sources)} 61 if (!empty($component->getAction())) {
62 $tpl->touchBlock(
"action_begin");
64 if (is_string($component->getAction())) {
65 $tpl->setCurrentBlock(
"with_href");
66 $tpl->setVariable(
"HREF", $component->getAction());
67 $tpl->parseCurrentBlock();
70 if (is_array($component->getAction())) {
71 $tpl->setCurrentBlock(
"with_href");
72 $tpl->setVariable(
"HREF",
"#");
73 $tpl->parseCurrentBlock();
74 $tpl->setCurrentBlock(
"with_id");
75 $tpl->setVariable(
"ID",
$id);
76 $tpl->parseCurrentBlock();
80 if (!is_array($component->getAction()) &&
$id !== null) {
81 $tpl->setVariable(
"IMG_ID",
" id='" .
$id .
"' ");
84 $tpl->setCurrentBlock($component->getType());
85 $tpl->setVariable(
"SOURCE", $component->getSource());
86 $tpl->setVariable(
"ALT", htmlspecialchars($component->getAlt()));
87 $tpl->parseCurrentBlock();
89 if (!empty($component->getAction())) {
90 $tpl->touchBlock(
"action_end");
101 return [Component\Image\Image::class];
109 parent::registerResources($registry);
110 $registry->
register(
'./src/UI/templates/js/Image/dist/image.min.js');
119 foreach ($resources as $min_width => $source) {
120 $map_entries .=
"[$min_width, '$source'],\n";
123 return "new Map([\n$map_entries])";
Registry for resources required by rendered output like Javascript or CSS.
getComponentInterfaceName()
checkComponent(Component $component)
Check if a given component fits this renderer and throw if that is not the case. ...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
registerResources(ResourceRegistry $registry)
Announce resources this renderer requires.
getHighResSourceMapForJs(array $resources)
getTemplate(string $name, bool $purge_unfilled_vars, bool $purge_unused_blocks)
Get template of component this renderer is made for.
register(string $name)
Add a dependency.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
render(Component $component, Renderer $default_renderer)
Render the component if possible and delegate additional rendering to the default_renderer.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Base class for all component renderers.
bindJavaScript(JavaScriptBindable $component)
Bind the component to JavaScript.