Permalink
Browse files

Merge pull request #46 from dave08/master

Separate image source
  • Loading branch information...
2 parents d2b124c + 0006b83 commit caf07d845f8df2b8ba91dec772a24373dddeef85 @avalanche123 avalanche123 committed Mar 31, 2012
@@ -42,6 +42,8 @@ class ImagineController
*/
private $webRoot;
+ private $sourceRoot;
+
/**
* Constructs by setting $cachePathResolver
*
@@ -58,7 +60,8 @@ public function __construct(
ImagineInterface $imagine,
FilterManager $filterManager,
Filesystem $filesystem,
- $webRoot
+ $webRoot,
+ $sourceRoot
)
{
$this->request = $request;
@@ -67,6 +70,7 @@ public function __construct(
$this->filterManager = $filterManager;
$this->filesystem = $filesystem;
$this->webRoot = $webRoot;
+ $this->sourceRoot = $sourceRoot;
}
/**
@@ -96,7 +100,7 @@ public function filter($path, $filter)
}
$realPath = $this->webRoot.$browserPath;
- $sourcePath = $this->webRoot.$path;
+ $sourcePath = $this->sourceRoot.$path;
// if the file has already been cached, we're probably not rewriting
// correctly, hence make a 301 to proper location, so browser remembers
@@ -32,7 +32,7 @@ public function load(array $configs, ContainerBuilder $container)
$container->setAlias('imagine', new Alias('imagine.'.$driver));
- foreach (array('cache_prefix', 'web_root', 'filters') as $key) {
+ foreach (array('cache_prefix', 'web_root', 'source_root', 'filters') as $key) {
if (isset($config[$key])) {
$container->setParameter('imagine.'.$key, $config[$key]);
}
View
@@ -155,6 +155,7 @@ The default configuration for the bundle looks like this:
``` yaml
avalanche_imagine:
+ source_root: %kernel.root_dir%/../web
web_root: %kernel.root_dir%/../web
cache_prefix: media/cache
driver: gd
@@ -163,6 +164,14 @@ avalanche_imagine:
There are several configuration options available:
+ - `source_root` - can be set to the absolute path to your original image's
+ directory. This option allows you to store the original image in a
+ different location from the web root. Under this root the images will
+ be looked for in the same relative path specified in the apply_filter
+ template filter.
+
+ default: `%kernel.root_dir%/../web`
+
- `web_root` - must be the absolute path to you application's web root. This
is used to determine where to put generated image files, so that apache
will pick them up before handing the request to Symfony2 next time they
@@ -8,6 +8,7 @@
<!-- Configuration defaults -->
<parameter key="imagine.web_root">%kernel.root_dir%/../web</parameter>
+ <parameter key="imagine.source_root">%kernel.root_dir%/../web</parameter>
<parameter key="imagine.cache_prefix">media/cache</parameter>
<parameter key="imagine.filters" type="collection" />
@@ -63,6 +64,7 @@
<argument type="service" id="imagine.filter.manager" />
<argument type="service" id="filesystem" />
<argument>%imagine.web_root%</argument>
+ <argument>%imagine.source_root%</argument>
</service>
<!-- Route Loader -->

0 comments on commit caf07d8

Please sign in to comment.