Skip to content

Commit

Permalink
Making the src_dir more flexible
Browse files Browse the repository at this point in the history
This allows the src_dir == public config
#13
  • Loading branch information
weotch committed Feb 7, 2015
1 parent d694710 commit 4c8e61b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Bkwld/Croppa/Croppa.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,12 @@ public function tag($src, $width = null, $height = null, $options = null) {
public function pattern() {
$pattern = '^';

// Make sure it starts with a src dir. This check involes stripping
// the document root out of the path and escaping them.
// Make sure it starts with a src dir
$pattern .= '(?:'.implode('|', array_map(function($dir) {
return preg_quote(str_replace($this->config['public'].'/', '', $dir), '#');
return preg_quote( // Escape unsafe chars
ltrim( // Don't allow leading slashes, the generate($path) lacks them
str_replace($this->config['public'], '', $dir),
'/'), '#');
}, $this->config['src_dirs'])).')';

// Add rest of the path up to croppa's extension
Expand Down

0 comments on commit 4c8e61b

Please sign in to comment.