diff --git a/Services/MediaObjects/Video/Service/class.GUIService.php b/Services/MediaObjects/Video/Service/class.GUIService.php index f9e325029e8f..3db7df3773d9 100644 --- a/Services/MediaObjects/Video/Service/class.GUIService.php +++ b/Services/MediaObjects/Video/Service/class.GUIService.php @@ -103,8 +103,26 @@ public function handleExtractionRequest( } } + protected function checkPreviewPossible(int $mob_id) : bool + { + if ($mob_id === 0) { + return false; + } + $mob = new \ilObjMediaObject($mob_id); + $med = $mob->getMediaItem("Standard"); + if (is_object($med)) { + if (\ilFFmpeg::supportsImageExtraction($med->getFormat())) { + return true; + } + } + return false; + } + public function addPreviewInput(\ilPropertyFormGUI $form, int $mob_id = 0) : void { + if (!$this->checkPreviewPossible($mob_id)) { + return; + } $lng = $this->domain_service->lng(); $pp = new \ilImageFileInputGUI($lng->txt("mob_preview_picture"), "preview_pic"); $pp->setSuffixes(array("png", "jpeg", "jpg")); @@ -122,6 +140,9 @@ public function addPreviewInput(\ilPropertyFormGUI $form, int $mob_id = 0) : voi public function savePreviewInput(\ilPropertyFormGUI $form, int $mob_id) : void { + if (!$this->checkPreviewPossible($mob_id)) { + return; + } $prevpic = $form->getInput("preview_pic"); if ($prevpic["size"] > 0) { $mob = new \ilObjMediaObject($mob_id); diff --git a/Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php b/Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php index 6937a1f0b99a..7d4f692c901f 100755 --- a/Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php +++ b/Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php @@ -379,7 +379,9 @@ public function initForm(string $a_mode = "create"): void $this->form_gui->addItem($ta); } - $this->video_gui->addPreviewInput($this->form_gui, $this->object->getId()); + if ($this->object) { + $this->video_gui->addPreviewInput($this->form_gui, $this->object->getId()); + } // standard parameters if ($a_mode == "edit" &&