This project is read-only.

Image Assistance...

Topics: Customizing Orchard, Writing modules
Jun 21, 2011 at 1:17 AM


I'm working on a project in which I need to do the following things with images:

  • Customize the directory and path of the images (/Media/Default/ does not work for me) virtual or physical.
  • Attach multiple image galleries for one content item.
  • Automatically Resize for Thumbnails

Naturally, I tried Media Folders (not entirely what i'm looking for) and Image Galleries modules, (they didnt play nice together), and image gallery is a part and not a field. 


So now I'm thinking of rolling my own solution but I don't have much time for trial and error.  Here's my initial thoughts -

  • create an image handler
    • Add a setting to configure it's valid handler path(s) to respond to off the root, ie: /Images or /Videos, or /Media or something else
    • Add an additional field in the Media content type for it's new virtual path  ie: "whatever/image_path/you-want.jpg"
    • image handler takes in the new virtual path ie: by returning the physical image in the form of an ImageResult
    • Overriding the "finalUrl" path for all media with the new virtual one, or the physical path if it's not set, so all media content will use this new path if it's set.
  • modify imagegallery module
    • allow it to be added as a field
  • extend image handler (eventually)
    • allow dynamic resizing


Anyone have any thoughts, advice, suggestions on any or all of that? Am I going about this the wrong way?


Jun 21, 2011 at 5:49 AM

Image Field does everything, instead of the gallery. You might want to extend it to allow a set of images.

Jun 21, 2011 at 7:20 AM

I have image field module installed... I'm not sure how I can configure it that way. Can you elaborate please?

Jun 21, 2011 at 7:38 AM

Maybe I wasn't clear... but I don't want my images served from 

I want something like

basically (Media/Default) needs to gtfo of all the URL's.

Can image field rid the site of media/default from all images it uploads?

Jun 21, 2011 at 7:49 AM

For what you need, my way of handling it would be through a controller action. It would be beneficial to have some form of convention for getting the right image based on the url requested.

When the request comes in, you can then serve the file from where it is stored. You can have the Route be anyway you like.

Jun 21, 2011 at 7:56 AM

Yea, well that's kind of what I was thinking: creating a controller to interpret the route and then mapping to the images shouldn't be a problem (that's the easy part for me).  

I want to make sure that I'm not doing something that is already implemented or doable already without having to write anything custom. 

Allowing the cms users the flexibility to determine the URL's is really what I'm after. 

Jun 21, 2011 at 4:02 PM

Hi Psy,

I don't know if you've seen my Media Garden project ( It doesn't do everything you're after right now, but the plan was to start adding those features. Since I got a major project out of the way on Friday I can start developing this more again.

Currently Media Garden gives you a flexible way to handle all kinds of media - Video, Audio, Images, Documents. It gives you a new media import screen ("Sources") where you can either upload files or paste in a URL, and any supported media formats it finds you can then import into your database as content items. So it works a bit differently than other media modules or the built-in system. Because each type of media is surfaced as a unique content type, you can add other parts to them; e.g. Stars, Tags or Comments; and each piece of media gets its own page (if you want). You can actually create several different content types for the same type of media, and pick which one you want when you import.

Dynamic image resizing is on my priority feature list. This will involve a handler of some kind, and I'd also been thinking about ways to manage the URLs cleverly for SEO purposes.

What I'm kind of thinking is that when you add an image to a page, that image should be on a sub-URL of that page.


- I have a page called /about-us

- I add an image called "My Company Photo.jpg".

- I want that image's URL to actually be /about-us/my-company-photo.jpg

Anyway; that's extremely complicated to do, and is a long-term goal that's non really necessary. The simple thing initially is to have a handler that like you suggest just gets rid of /Media/Default and can perform resizing.

In terms of image galleries, Media Garden already has an approach that will do what you need, if you combine it with my Mechanics module. Because in Media Garden all your images are content, then creating a gallery is just a matter of creating another content item that's a list of images. Using the Mechanics connectors it's easy to do that, and then there's nothing stopping you also creating lists of galleries. Mechanics displays fields for connected items (it'll choose dropdown or checkbox list based on the relationship, and I'm currently extending Media Garden so it create an uploader field as well).

Sorry that possibly all sounds a bit complicated, I'm not explaining things very well today. But what I'm saying is that I've designed Media Garden to be extended to do exactly those things, and it's open source so if you wanted to work with me on getting them implemented, it could be ready really soon.

Jun 22, 2011 at 8:41 AM
Edited Jun 22, 2011 at 4:25 PM

What is the right way to go about extending the MediaItem with an additional field?  (then the controller that updates the model, etc)


Also, Pete, I sent you a PM

Jun 22, 2011 at 11:15 AM
Edited Jun 22, 2011 at 8:05 PM

Edit: Meant to reply to PM, somehow it ended up here...