Skip to content

Instantly share code, notes, and snippets.

@ahuggins
Created February 26, 2017 03:08
Show Gist options
  • Select an option

  • Save ahuggins/39ce8408046ae9d406f6cf45baa652e2 to your computer and use it in GitHub Desktop.

Select an option

Save ahuggins/39ce8408046ae9d406f6cf45baa652e2 to your computer and use it in GitHub Desktop.
Image Class
<?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');
}
}
@ahuggins
Copy link
Copy Markdown
Author

Want to use a PHP magic method to make this cleaner/better, but rough for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment