Created
February 26, 2017 03:08
-
-
Save ahuggins/39ce8408046ae9d406f6cf45baa652e2 to your computer and use it in GitHub Desktop.
Image Class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace App; | |
| class Image | |
| { | |
| protected $path; | |
| public function __construct($path) | |
| { | |
| $this->path = pathinfo($path); | |
| } | |
| public function image($version) | |
| { | |
| return url($this->path['dirname'] . '/' . $this->path['filename'] . '-' . $version . '.' . $this->path['extension']); | |
| } | |
| public function thumbnail() | |
| { | |
| return $this->image('cropped'); | |
| } | |
| public function full() | |
| { | |
| return url($this->path['dirname'] . '/' . $this->path['filename'] . '.' . $this->path['extension']); | |
| } | |
| public function cropped() | |
| { | |
| return $this->image('cropped'); | |
| } | |
| public function medium() | |
| { | |
| return $this->image('medium'); | |
| } | |
| public function small() | |
| { | |
| return $this->image('small'); | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Want to use a PHP magic method to make this cleaner/better, but rough for now