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

Add Resize and RelativeResize filters #37

Merged
merged 1 commit into from
Nov 16, 2011
Merged

Add Resize and RelativeResize filters #37

merged 1 commit into from
Nov 16, 2011

Conversation

jmikola
Copy link
Contributor

@jmikola jmikola commented Nov 11, 2011

Ported these over from JmikolaImagineBundle, with some modifications to accomodate LiipImagineBundle's LoaderInterface. These can potentially replace the existing Thumbnail filter.

@lsmith: Please let me know if anything is missing. I think the DI configuration was all that this needed apart from the classes themselves.

Ported these over from JmikolaImagineBundle, with some modifications to accomodate LiipImagineBundle's LoaderInterface. These can potentially replace the existing Thumbnail filter.
return $filter->apply($image);
}

throw new InvalidArgumentException('Expected method/parameter pair, none given');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems like a really weird way to configure the filter. What if the user sets several entries in the option array ?

another issue is that it introduces a limitation in how it can be used from Twig: hash keys cannot be set dynamically with variables so it is impossible to set the method according to a parameter (which could be useful when making it configurable). Why not using array('method' => $method, 'parameter' => $parameter) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't consider how filter parameters are defined for LiipImaigneBundle. For the original bundle, I have the following in my yaml configuration:

featured_logo:
    type:    relative_resize
    options: { heighten: 78 }
dashboard_avatar:
    type:    relative_resize
    options: { widen: 170 }

Separate method and parameter keys there would have been superfluous. Only one method can specified at a time, and they each have a single parameter. On the subject of combining multiple operations, I think @lsmith told me that would be possible with a filter chain he had in this bundle.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, after reading through this bundle's documentation, I still don't see any examples of configuring these filters in Twig. I just see them setup in YAML and then referred to in Twig by name. Can you point me towards an example?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, options come from the config, not from the Twig function. Missed this point.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we're all good here? :)

The foreach syntax was just some shorthand to avoid calling key() and current). I'm definitely not using it for iteration.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, but this is quite confusing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lsmith77: What's your opinion here. Do you want me to use key() and current() or perhaps make the configuration more verbose so that method and parameter must be specified by their own keys?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm yeah .. i guess key() and current() would indeed be better. could you send another PR with that change .. but more importantly could you fix the README? i already added some docs there, but they are incomplete.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do. I completely dropped the ball on porting over my README docs, sorry.

lsmith77 added a commit that referenced this pull request Nov 16, 2011
Add Resize and RelativeResize filters
@lsmith77 lsmith77 merged commit a612b16 into liip:master Nov 16, 2011
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

Successfully merging this pull request may close these issues.

None yet

3 participants