Skip to content

Commit

Permalink
Use a constant to define the default thumbs location.
Browse files Browse the repository at this point in the history
  • Loading branch information
beryllium committed May 20, 2017
1 parent 756cb82 commit ff50658
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Beryllium\Icelus\DependencyInjection;

use Beryllium\Icelus\ImageService;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

Expand All @@ -21,7 +22,7 @@ public function getConfigTreeBuilder()

$rootNode
->children()
->scalarNode('prefix')->defaultValue('/_thumbs')->end()
->scalarNode('prefix')->defaultValue(ImageService::DEFAULT_PREFIX)->end()
->scalarNode('output_dir')->defaultNull()->end()
->end();

Expand Down
6 changes: 4 additions & 2 deletions ImageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,23 @@ class ImageService
public $prefix;
public $completed = array();

const DEFAULT_PREFIX = '/_thumbs';

/**
* Constructor
*
* @param Imanee $imanee Performs the required image manipulations
* @param string $source_dir Where to find the images
* @param string $output_dir Where to save the images
* @param string $prefix prefix path for images
* @param string|null $prefix subdirectory under output_dir to save the images (Default: '/_thumbs')
* @param Filesystem $filesystem Filesystem class for doing filesystem things
*/
public function __construct(Imanee $imanee, $source_dir, $output_dir, $prefix, Filesystem $filesystem)
{
$this->imanee = $imanee;
$this->source_dir = rtrim($source_dir, '/');
$this->output_dir = rtrim($output_dir, '/');
$this->prefix = $prefix;
$this->prefix = $prefix ? rtrim($prefix, '/') : static::DEFAULT_PREFIX;
$this->filesystem = $filesystem;
}

Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,16 @@ __Note:__ The class name should be a string, not an object instantiation. (This
Configuration
-------------

Add to `sculpin_kernel.yml`
Generally, no additional configuration is required. If you want to rename
the output subfolder for thumbnails (default is 'yourblog.com/_thumbs'),
add this to your `sculpin_kernel.yml`

``` yml
icelus:
prefix: '/_thumbs'
```
* `icelus.prefix` : A part of the path used as the prefix of the output path. default is `'/_thumbs'`.
* `icelus.prefix` : A subdirectory under the Sculpin output directory to store the thumbnails. Default is `'/_thumbs'`.

Usage
-----
Expand Down

0 comments on commit ff50658

Please sign in to comment.