This project is read-only.

insert image without hardcoded path

Topics: Core, Troubleshooting
Oct 17, 2012 at 10:32 AM



When creating a new page in Orchard and adding an image through the media/image picker, the html tag <img src="/Media/Default/Page/something.png" /> is added.

However, when deploying or moving the Orchard site to a new/other virtual directory, the image path breaks. E.g., from to

I can solve this by removing the first "/" in the img src attribute; this will display the image because of the relative path. Unfortunately, the image breaks in the Edit Page (admin dashboard).


What is the recommended / best practice to handle this issue? How should I construct the src attribute such that (1) the site can be moved to a new/renamed virtual directory without breaking the images and (2) the image does not break in the admin dashboard?


Thanks for the suggestions,

Robbie De Sutter

Oct 17, 2012 at 5:55 PM

Always set-up your dev environment the same way you set-up your production environment.

Oct 17, 2012 at 7:42 PM

I agree that, if we configure the dev & production environment identical, there will be no problem.

However, if next year we  move the site to a new location / virtual directory (for example to archive the site), then all img links will be broken.

Oct 17, 2012 at 8:38 PM

You could implement a custom HTML filter which would convert it. For instance there is currently one which will convert bbcode. This was its original purpose I think.

Take a look at BbcodeFilter and MarkdownFilter classes for examples.