예제 #1
0
     checkUserAPI();
     break;
 case 'checkEmail':
     checkUserEmail();
     break;
 case 'sendEmail':
     sendMail();
     break;
 case 'insertLecture':
     addLecture();
     break;
 case 'savePrice':
     insertPrice();
     break;
 case 'insertThumbnail':
     saveThumbnail();
     break;
 case 'updateThumbnail':
     changeThumbnail();
     break;
 case 'uploadMashup':
     uploadMashup();
     break;
 case 'displayLD':
     displayLD();
     break;
 case 'saveNotes':
     insertNotes();
     break;
 case 'setFBdetails':
     saveFBdetails();
 public static function saveThumbnails($list)
 {
     function saveThumbnail($imagePath, $width, $height)
     {
         $imgContent = file_get_contents($imagePath);
         $image = imagecreatefromstring($imgContent);
         $origWidth = imagesx($image);
         $origHeight = imagesy($image);
         $pathParts = pathinfo($imagePath);
         $thumbPath = $pathParts['dirname'] . '/' . $pathParts['basename'] . '_thumb.jpg';
         $thumbImage = imagecreatetruecolor($width, $height);
         imagecopyresampled($thumbImage, $image, 0, 0, 0, 0, $width, $height, $origWidth, $origHeight);
         imagejpeg($thumbImage, $thumbPath, 90);
     }
     $ogImages = (array) $list->ogImages;
     if (!empty($ogImages['main'])) {
         if (strpos($ogImages['main'], 'http://') === 0 || strpos($ogImages['main'], 'https://') === 0) {
             throw new InvalidArgumentException("You shouldn't use remote images for Og images. Please upload them!");
         }
         if (file_exists(public_path($ogImages['main']))) {
             saveThumbnail(public_path($ogImages['main']), 400, 210);
         }
     }
     /*foreach($ogImages as $ogImage) {
           if(!empty($ogImage) && file_exists('.' . $ogImage)) {
               saveThumbnail('.' . $ogImage, 210, 400);
           }
       }*/
 }
 public static function saveThumbnails($list)
 {
     function saveThumbnail($imagePath, $width, $height)
     {
         $thumbPath = ListHelpers::getListThumbPathFromImage($imagePath);
         try {
             Image::make($imagePath)->fit($width, $height)->save($thumbPath);
         } catch (Intervention\Image\Exception\NotReadableException $e) {
             throw new Exception('Error saving thumbnail! Invalid image!');
         } catch (Intervention\Image\Exception\NotWritableException $e) {
             throw new Exception('Error saving thumbnail! Permission issue! Contact site admin');
         }
     }
     if (file_exists(public_path(!$list->image))) {
         saveThumbnail(public_path($list->image), 400, 210);
     } else {
         throw new Exception('Banner image of the list not found. Please add an image!');
     }
 }