19 declare(strict_types=1);
30 protected function deleteImage($image_filename): void
32 $imagepath = $this->getImagePath();
33 @unlink($imagepath . $image_filename);
34 $thumbpath = $imagepath . $this->getThumbPrefix() . $image_filename;
38 private function cloneImages(
39 int $source_question_id,
40 int $source_parent_id,
41 int $target_question_id,
42 int $target_parent_id,
45 $image_source_path = $this->getImagePath($source_question_id, $source_parent_id);
46 $image_target_path = $this->getImagePath($target_question_id, $target_parent_id);
48 if (!file_exists($image_target_path)) {
51 $this->removeAllImageFiles($image_target_path);
54 foreach ($answers as $answer) {
60 if (!file_exists($image_source_path .
$filename)
61 || !copy($image_source_path . $filename, $image_target_path . $filename)) {
62 $this->log->root()->warning(
'Image could not be cloned for object for question: ' . $target_question_id);
64 if (!file_exists($image_source_path . $this->getThumbPrefix() . $filename)
65 || !copy($image_source_path . $this->getThumbPrefix() . $filename, $image_target_path . $this->getThumbPrefix() . $filename)) {
66 $this->log->root()->warning(
'Image thumbnail could not be cloned for object for question: ' . $target_question_id);
71 public function rebuildThumbnails(
77 if (!$is_single_line || $thumbnail_size === 0) {
81 foreach ($answers as $answer) {
82 if ($answer->getImage() ===
null || $answer->getImage() ===
'') {
86 $thumb_path = $image_path . $this->getThumbPrefix() . $answer->getImage();
87 if (file_exists($thumb_path)) {
91 $current_file_path = $image_path . $answer->getImage();
92 if (!file_exists($current_file_path)) {
95 $new_file_name = $this->buildHashedImageFilename($answer->getImage(),
true);
96 $new_file_path = $image_path . $new_file_name;
97 rename($current_file_path, $new_file_path);
98 $answer->setImage($new_file_name);
100 $this->generateThumbForFile(
110 public function getThumbPrefix(): string
115 public function generateThumbForFile(
120 $file_path = $image_path . $file_name;
121 if (!file_exists($file_path)) {
125 $thumb_path = $image_path . $this->getThumbPrefix() . $file_name;
126 $path_info = pathinfo($file_path);
128 switch (strtoupper($path_info[
'extension'])) {
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static convertImage(string $a_from, string $a_to, string $a_target_format="", string $a_geometry="", string $a_background_color="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...