ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilImagePathResolver.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24{
25 public function resolveImagePath(string $image_path): string
26 {
27 global $DIC;
28
29 $styleDefinition = $DIC["styleDefinition"] ?? null;
30
31 // default image
32 $default_img = "./assets/images/" . $image_path;
33
34 // use ilStyleDefinition instead of account to get the current skin and style
35 $current_skin = ilStyleDefinition::getCurrentSkin();
36 $current_style = ilStyleDefinition::getCurrentStyle();
37
38 $skin_img = "";
39
40 if (is_object($styleDefinition) && $current_skin != "default") {
41 $image_dir = $styleDefinition->getImageDirectory($current_style);
42 $skin_img = "./Customizing/skin/" .
43 $current_skin . "/" . $current_style . "/" . $image_dir . "/" . $image_path;
44 }
45
46 if (file_exists($skin_img)) {
47 return $skin_img; // found image for skin and style
48 }
49
50 return $default_img; // take image in default
51 }
52}
resolveImagePath(string $image_path)
static getCurrentSkin()
get the current skin use always this function instead of getting the account's skin the current skin ...
static getCurrentStyle()
get the current style or sub style use always this function instead of getting the account's style th...
Some Components need to resolve pathes to image-files.
global $DIC
Definition: shib_login.php:26