/** * @param \App\Repos\Files\File $file * @param int $sizeConstraint */ public function make($file, $sizeConstraint = 170) { if (!$this->isPhoto($file->getSystemPath() . $file->filename)) { return; } // get and make sure the thumbnail system path is created $thumbnail_system_path = $file->getThumbnailSystemPath(); $thumbnail_url_path = $file->getThumbnailURLPath(); $thumbnail_name = '$sizeConstraint-' . $file->filename; \Image::make($file->getSystemPath() . $file->filename)->resize($sizeConstraint, null, function ($constraint) { $constraint->aspectRatio(); })->save($thumbnail_system_path . $thumbnail_name); $file->thumbnail = $thumbnail_url_path . $thumbnail_name; }
/** * Generates a thumbnail for image file types * * @param File $file */ public function generateThumbnail($file) { // get and make sure the thumbnail system path is created $thumbnail_system_path = $file->getThumbnailSystemPath(); $thumbnail_url_path = $file->getThumbnailURLPath(); $thumbnail_name = '170-' . $file->filename; \Image::make($file->getSystemPath() . $file->filename)->resize(170, null, function ($constraint) { $constraint->aspectRatio(); })->save($thumbnail_system_path . $thumbnail_name); $file->thumbnail = $thumbnail_url_path . $thumbnail_name; }