Hi all I created a little extension for image variations so that I'm able to configure image operations per variation. E.g. adding a blur effect on variation 'teaser'.
The documentation states: [quote]The imaging module can resize and crop images, overlay text and apply image filters. These are called image operations. Operations are configured in /modules/imaging/config/generators or, in the case of STK, in a theme using variations.[/quote] http://documentation.magnolia-cms.com/modules/imaging.html#Imageoperations That sentence probably is somewhat misleading because the only supported operations on variations are crop/resize. However, the STK image generator already handles operation chains, so all I did was extending the default variation class SimpleResizeVariation and used it for configuring more complex variations: [code] @SuppressWarnings("deprecation") public class ExtendedImageVariation extends SimpleResizeVariation { private final List<ImageOperation<ParameterProvider<NodeData>>> operations; public ExtendedImageVariation(final Provider<Site> siteProvider) { super(siteProvider); this.operations = new ArrayList<ImageOperation<ParameterProvider<NodeData>>>(); } public List<ImageOperation<ParameterProvider<NodeData>>> getOperations() { return this.operations; } public void addOperation(final ImageOperation<ParameterProvider<NodeData>> operation) { this.operations.add(operation); } @Override public void init() { super.init(); final ImageOperationChain<ParameterProvider<NodeData>> newOperationChain = new ImageOperationChain<ParameterProvider<NodeData>>(); newOperationChain.addOperation(this.getImageOperation()); for (final ImageOperation<ParameterProvider<NodeData>> operation : this.operations) { newOperationChain.addOperation(operation); } this.setImageOperation(newOperationChain); } } [/code] Variation configuration example: - teaser -- class: ExtendedImageVariation -- operations --- blur ---- class: info.magnolia.imaging.operations.BufferedImageOpDelegate ---- delegate ----- class: com.jhlabs.image.BlurFilter It works the same way like configuring operations for /modules/imaging/config/generators Any comments/suggestions? Please tell me if this feature was already present in Magnolia and I completely missed it ;) Cheers Andy -- Context is everything: http://forum.magnolia-cms.com/forum/thread.html?threadId=298a796c-7406-4d9e-bd04-4682d3d91666 ---------------------------------------------------------------- For list details, see http://www.magnolia-cms.com/community/mailing-lists.html Alternatively, use our forums: http://forum.magnolia-cms.com/ To unsubscribe, E-mail to: <[email protected]> ----------------------------------------------------------------
