19 declare(strict_types=1);
33 protected string $ext =
'';
37 private ?
string $obj_type,
51 public function withRid(?
string $rid): self
59 ImageFactory $image_factory
61 if ($this->rid !==
null 63 && ($resource = $this->storage_services->manage()->find($this->rid)) !==
null 69 if ($this->object_type_specific_property_providers !==
null &&
71 $specific_tile_image = $this->object_type_specific_property_providers->getObjectTypeSpecificTileImage(
74 $this->storage_services
77 return $specific_tile_image;
82 return $image_factory->responsive(
$path,
'');
88 ImageFactory $image_factory,
91 $flavour = $this->storage_services->flavours()->get($resource, $this->flavour_definition);
92 $urls = $this->storage_services->consume()->flavourUrls($flavour)->getURLsAsArray();
97 $available_widths = $this->flavour_definition->getWidths();
98 array_pop($available_widths);
100 if (!isset($urls[count($available_widths)])) {
104 $image = $image_factory->responsive($urls[count($available_widths)],
'');
107 function ($carry, $size) use ($urls) {
108 $image = $carry[
'image']->withAdditionalHighResSource($urls[$carry[
'counter']], $size / 2);
109 $counter = ++$carry[
'counter'];
112 'counter' => $counter
115 [
'image' => $image,
'counter' => 0]
126 if ($this->rid ===
null || $this->rid ===
'') {
130 $resource = $this->storage_services->manage()->find($this->rid);
131 if ($resource ===
null) {
135 $flavour = $this->storage_services->flavours()->get($resource, $this->flavour_definition);
136 $urls = $this->storage_services->consume()->flavourUrls($flavour)->getURLsAsArray(
false);
138 return array_pop($urls) ??
'';
143 $clone = clone $this;
144 $clone->object_id = $new_object_id;
146 if ($this->rid !==
null 147 && ($rid = $this->storage_services->manage()->find($this->rid)) !==
null) {
148 $i = $this->storage_services->manage()->clone($rid);
149 $clone->rid = $i->serialize();
159 $sourceList = $sourceFS->listContents($sourceDir,
true);
161 foreach ($sourceList as $item) {
162 if ($item->isDir()) {
166 $path = $source_dir . DIRECTORY_SEPARATOR . basename($item->getPath());
168 $i = $this->storage_services->manage()->stream($stream, $this->storage_stakeholder,
'Tile Image');
169 $this->rid = $i->serialize();
static createRelativePath(string $absolute_path)
Creates a relative path from an absolute path which starts with a valid storage location.
createFromImportDir(string $source_dir)
getImage(ImageFactory $image_factory)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getImageFromIRSS(ImageFactory $image_factory, ResourceIdentification $resource)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ResourceIdentification.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
cloneFor(int $new_object_id)
static deriveFilesystemFrom(string $absolute_path)
Tries to fetch the filesystem responsible for the absolute path.
__construct(private int $object_id, private ?string $obj_type, private ?string $rid, private ResourceStorageServices $storage_services, private Stakeholder $storage_stakeholder, private FlavourDefinition $flavour_definition, private ?ObjectTypeSpecificPropertyProviders $object_type_specific_property_providers)
This is how the factory for UI elements looks.