How to override images provided by a module?

Topics: Writing themes
Mar 12, 2012 at 8:54 PM

Hi everyone, 

According to the documentation a theme can override images provided by a module.

But I could not accomplish that. 

For example I have the following code within a module: <img alt="" src="reference to an image"/>. I have two themes and both should provide its own versions of the image.    

How can I override an image provided by a module through a theme?

Coordinator
Mar 13, 2012 at 1:37 AM

override the template that has the image tag, point it to whatever you want.

Mar 13, 2012 at 8:15 AM
bertrandleroy wrote:

override the template that has the image tag, point it to whatever you want.

Thank you for your answer, but isn't this solution messy? For example in case of existence of 5 themes once we have changed a template within a module we have to reflect those changes in 5 themes. 

As far as I know there used to be a method called Html.ContenFolderUrl and that method was what we need. Why was it removed?  

Are you going to invent a more handy solution for overriding images?

Coordinator
Mar 13, 2012 at 8:37 AM

images are being served directly by IIS. Anything else would kill performance.

Mar 14, 2012 at 7:28 AM
bertrandleroy wrote:

images are being served directly by IIS. Anything else would kill performance.

Thank you very much for your answers!

Mar 14, 2012 at 9:43 AM
bertrandleroy wrote:

images are being served directly by IIS. Anything else would kill performance.


Any tips on how to improve performance when my module 'has' to stream a file?

Currently, I disabled the session with [SessionState(SessionStateBehavior.Disabled)] on my controller.

Also, I stream the file back using return File("*", "*");

So now I wonder if there is anything else I can do to improve performance for streaming files like this.

Coordinator
Mar 14, 2012 at 9:52 AM

Don't stream *all* images because you need to stream a few. For those images that you need to stream, there is an extremely efficient way of doing it (TransferFile IIRC). MVC has a file result of sorts that does the right thing I think. But no matter what, just having to go through the managed pipeline instead of being directly served by IIS is always going to be a lot slower. Your only chance is to do it as little as possible (by using kernel cache).

Mar 14, 2012 at 9:54 AM

Thanks about the 'TransferFile' remark. I'll try using that.