Image Filters and Media Profiles in Orchard CMS Media Processing
I love the extensibility hooks in Orchard CMS. Recently I created a new activity for the Orchard CMS Workflow Module, which was a lot of fun. Now I created a new image filter that can be activated either independently though a custom media shape or as part of Media Profiles in the new Media Processing Module in Orchard CMS.
Media Processing Module in Orchard CMS
In Orchard 1.7 we get a new media library, image editor, and media processing module that will be a lot of fun for creative types to show off their audio, images, and videos on their Orchard Websites. The Media Processing Module currently consists of image filters, custom media shapes, and media profiles. Over a weekend I dove deep into the code and built a custom Orchard widget, image filter, and custom media shape to better understand their functionality and relationship. I was pretty impressed by the simplicity in which I was able to create an image filter, add it to media profiles, and then inject numerous images from the media library through the filter pipeline. It was also fun to create a custom filter shape so that you can activate the filter without attaching it to a media profile. Orchard developers will really have fun with this.
Custom Image Filter in Orchard CMS
Two image filters come baked into Orchard 1.7: FormatFilter and ResizeFilter. The Format Filter will change the format of your image to a jpg, gif, or png as well as change the quality of the image. The Resize Filter in Orchard CMS will adjust the size of the photo, which is perfect for displaying thumbnails on Orchard Pages, portfolios, etc.
I created an Image filter that adds text to photos. I call it a Text Image Filter, which can be used to add copyright information as well as any text to the photo. Below you will see screenshots on how to add an Image Filter to a Media Profile and the custom Form I developed to display various image filter settings thanks to the cool Forms API in Orchard CMS. Note that this is the same Forms API used to create forms when developing custom activities in the Orchard Workflow Module.
Here is an example of adding text on a photo after it has been resized and stretched to 400px x 400px. Note that the original image is untouched. This is a new photo that has been generated by the image filter pipeline via Media Profiles to be shown to the visitor.
Media Shapes to Activate Filters Without Needing Media Profiles
I also want to mention you can create media shapes to display images without the need of creating Media Profiles. If you take a peek at the Orchard 1.7 source code you will see two media shapes: ResizeMediaUrl and MediaUrl. The ResizeMediaUrl Shape allows you to display a resized image using the ResizeFilter without the need of adding the filter to a Media Profile.
As you can probably guess, I created a similar shape, called TextMediaUrl, that displays an image with watermark/copyright text without the need of adding the custom Text Image Filter to a Media Profile. It is all very easy if you just follow the ResizeMediaUrl Example in the Orchard 1.7 source code.
As you can probably tell, I am pretty excited about Orchard 1.7. I have written a lot of tutorials on the new features:
- New Content Definition Menu Item in Orchard CMS
- Output Cache Module in Orchard CMS for Orchard Performance
- Extending Orchard Workflows with Custom Activities
- Run Orchard Recipes from Orchard Dashboard in Orchard CMS 1.7
- Media Manager and Image Editor in Orchard CMS 1.7
- Orchard Workflow Module in Orchard 1.7
- Content Picker has Content Type Filtering in Orchard CMS 1.7
- Shape Link for Orchard Menus in Orchard 1.7
- Orchard Content Type Layer Rule in Orchard CMS 1.7
I've also already developed custom activities for the Orchard Workflow Module and now a custom image filter for the Media Processing Module before Orchard 1.7 has been released. I'm probably overdoing it a bit :)
Twitter and Google+
Orchard Developer for Hire
I have been developing Orchard Modules, Orchard Themes, and Orchard Websites full-time for 3 years as of this summer, so if you are looking for an Orchard Developer, please contact me!