Browse Source

Create 64 pixel version of LP image see BT#16173

Julio 5 years ago
parent
commit
f9db054155
1 changed files with 11 additions and 1 deletions
  1. 11 1
      src/Chamilo/CourseBundle/Component/CourseCopy/CourseRestorer.php

+ 11 - 1
src/Chamilo/CourseBundle/Component/CourseCopy/CourseRestorer.php

@@ -2652,13 +2652,14 @@ class CourseRestorer
                     }
                 }
 
-                // Adding the author's image
+                // Adding the LP image
                 if (!empty($lp->preview_image)) {
                     $new_filename = uniqid('').substr(
                         $lp->preview_image,
                         strlen($lp->preview_image) - 7,
                         strlen($lp->preview_image)
                     );
+
                     if (file_exists($origin_path.$lp->preview_image) &&
                         !is_dir($origin_path.$lp->preview_image)
                     ) {
@@ -2668,6 +2669,15 @@ class CourseRestorer
                         );
                         if ($copy_result) {
                             $lp->preview_image = $new_filename;
+                            // Create 64 version from original
+                            $temp = new \Image($destination_path.$new_filename);
+                            $temp->resize(64);
+                            $pathInfo = pathinfo($new_filename);
+                            if ($pathInfo) {
+                                $filename = $pathInfo['filename'];
+                                $extension = $pathInfo['extension'];
+                                $temp->send_image($destination_path.'/'.$filename.'.64.'.$extension);
+                            }
                         } else {
                             $lp->preview_image = '';
                         }