/** * 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; }
/** * @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; }
public function deleteMultipleFiles($fileIds) { if (File::destroy($fileIds)) { return true; } else { return false; } }
/** * Gets the system path that all thumbnails for this model are stored on * Is used for storing thumbnails to the file system * * @return string */ public function getThumbnailSystemPath() { $path = $this->getSystemPath() . 'thumbnails/'; \File::exists($path) or \File::makeDirectory($path); return $path; }