19declare(strict_types=1);
35 protected \ILIAS\MediaObjects\MediaObjectRepository
$repo;
45 $this->media_manager = $this->domain->mediaObject();
46 $this->image_converters =
new Images(
true);
48 $this->repo =
$repo->mediaObject();
53 return "thumbs/Standard.png";
61 $mob = new \ilObjMediaObject($mob_id);
62 $item = $mob->getMediaItem(
"Standard");
64 if ($item?->getFormat() ===
"image/svg+xml") {
65 return $mob->getStandardSrc();
70 if ($this->media_manager->hasLocalFile($mob_id, $thumb_path)) {
71 return $this->media_manager->getLocalSrc($mob_id, $thumb_path);
76 if ($preview_src !==
"") {
81 if ($item?->getLocationType() ===
"LocalFile") {
82 if ($item?->getThumbTried() !==
"y") {
85 $item?->getLocation(),
89 $item?->writeThumbTried(
"y");
90 if ($this->media_manager->hasLocalFile($mob_id, $thumb_path)) {
91 return $this->media_manager->getLocalSrc($mob_id, $thumb_path);
95 if (str_starts_with($item?->getFormat(),
"image/")) {
96 return $item?->getLocation();
101 return \ilUtil::getImagePath(
"standard/icon_mob.svg");
108 string $target_location,
110 $is_image = is_int(strpos($format,
"image/"));
112 if (!$this->media_manager->hasLocalFile($mob_id,
$location)) {
120 $tempStream = fopen(
'php://temp',
'w+');
121 stream_copy_to_stream($this->media_manager->getLocationStream($mob_id,
$location)->detach(), $tempStream);
123 $stream =
new Stream($tempStream);
130 $this->output_options
131 ->withQuality($image_quality)
134 $this->media_manager->addStream(
137 $converter->getStream()
149 string $target_location =
"mob_vpreview.png"
152 $is_image = is_int(strpos($format,
"image/"));
153 $is_video = in_array($format, [
"video/mp4",
"video/webm"]);
162 $tempStream = fopen(
'php://temp',
'w+');
163 stream_copy_to_stream($this->repo->getLocationStream($mob_id,
$location)->detach(), $tempStream);
165 $stream =
new Stream($tempStream);
167 $converter = $this->resizeToFixedSize(
172 $this->output_options
173 ->withQuality($image_quality)
176 $this->repo->addStream(
179 $converter->getStream()
184 $zip_uri = $this->repo->getContainerPath($mob_id);
190 $png_res = fopen(
'php://memory',
'r+');
191 fwrite($png_res, $image_str);
193 $png_stream =
new Stream($png_res);
194 $this->repo->addStream(
208 bool $crop_if_true_and_resize_if_false,
212 ->withMakeTemporaryFiles(false)
213 ->withThrowOnError(false)
214 ->withBackgroundColor(
'#FFFFFF');
219 ->withHeight($height)
220 ->withCrop($crop_if_true_and_resize_if_false)
221 ->withKeepAspectRatio(
true),
236 "mob_vpreview.jpeg");
237 foreach ($ppics as $pic) {
238 if ($this->media_manager->hasLocalFile($mob_id, $pic)) {
239 return $this->media_manager->getLocalSrc($mob_id, $pic);
static extractPNGFromVideoInZip(string $zip, string $path, int $sec=1)