Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic options for Imagine filter #22

Closed
petrjaros opened this issue Jun 27, 2011 · 3 comments
Closed

Dynamic options for Imagine filter #22

petrjaros opened this issue Jun 27, 2011 · 3 comments

Comments

@petrjaros
Copy link
Contributor

It's not possible to provide options to Imagine filter through a route. E.g. set an image size dynamically:

/media/cache/filter/path/to/my/file/file-800-600.png

for file

/path/to/my/file/file.png

My proposal is to add one more parameter in AvalancheImagineBundle configuration:

avalanche_imagine:
    filters:
        dynamic_size:
            type:    thumbnail
            options: { mode: outbound } #static options
            route: {directory}/{file}-{width}-{height}.{extension} #optional parameter
            #route: {directory}/{file}.{extension} #default setting of route parameter

Directory, file and extension parameters in the route are built-in and create the path to the file. Other parameters are sent to the filter, width and height are sent to the thumbnail filter in this case.
Twig filter could look like this:

'path/to/my/file/file.png'|apply_filter('dynamic_size', {width: 800, height: 600})

This solution has also one security issue - allows attacker to create huge amount of cached files. It could be solved with some constant number determinig the maximum number of possible caches per one image file.
What do you think about this? If you'll like this proposal I can make a pull request.

Peter

@avalanche123
Copy link
Owner

I think image size need to be configured to avoid security risks, it is a little more work but a much better result

@petrjaros
Copy link
Contributor Author

Ok, it was only an example. Let's imagine another filter designed for image cropping or changing of the color... Sometimes it's not possible to create so many combinations in static configuration. The beauty of Imagine filters is lost in this bundle when you cannot set options dynamically.

@avalanche123
Copy link
Owner

I don't think it is bad to configure your filters in advance, any dynamic configuration from url is potentially abusable by end users

Bluestart83 pushed a commit to Bluestart83/AvalancheImagineBundle that referenced this issue Jun 10, 2013
Bluestart83 pushed a commit to Bluestart83/AvalancheImagineBundle that referenced this issue Jun 10, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants