Skip to content
Robert Reinhard edited this page Apr 2, 2015 · 12 revisions

4.0

Config changes

  • src_dir is the dir where the path is looked for. For me, this is typically public_path().'/uploads'. But, this could potentially be app_path().'/storage/assets' or a Flysystem instance bound to the IoC container.
  • crop_dir is where crops are created. For me, this is typically public_path.'/uploads' as well. But, it could be public_path.'/uploads' or a Flysystem instance bound to the IoC container.
  • whitelist is a callable that allows requests to be rejected. function($path) { // return boolean }

Examples

Current

  • Asset : /public/uploads/bar.jpg
  • Request : http://domain.com/uploads/bar-200x100.jpg
  • src_dir : /public
  • crop_dir : /public
  • whitelist : function($path) { return preg_match('#^uploads#', $path); }

The whitelist allows the request. The path from the request can be appended to the src_dir to find the asset. A crop is created and stored in the crop_dir at the requested path. On the next request, apache can server that crop directly.

Different, local src dir

This is the case of #36

  • Asset : /storage/assets/bar.jpg
  • Request : http://domain.com/assets/bar-200x100.jpg
  • src_dir : /storage
  • crop_dir : /public
  • whitelist : function($path) { return preg_match('#^assets#', $path); }

Works the same as previous example.

  • I don't like that it HAS to be /storage/assets/bar.jpg and not just /storage/bar.jpg. Maybe I want to introduce a prefix config? Or pattern to get the path from the URL. Like maybe I don't use parse_url and have a regex to get the path that can be edited. But, by default, it's everything from the domain up to the query string

Clone this wiki locally