Image fails to load in content part

Topics: Writing modules
Mar 14, 2012 at 5:48 AM

I have added an image to the view of a content part

<img src="@Url.Content("~/Themes/MyTheme/Content/Images/loading.gif")"/>

The image fails to load with the Url (/Orchard/Themes/MyTheme/Content/Images/loading.gif).  I have checked the image file is in the Images folder.

Previously, I was able to get the image to load with Html.ThemePath but now it requires an extension descriptor and I am not sure how I can supply it a descriptor.

Coordinator
Mar 14, 2012 at 6:28 AM

My bet is that you don't have the necessary web.config in that directory.

Coordinator
Mar 14, 2012 at 5:48 PM

And please check that you have it in /Content, and do not have one in /Content/Images. Otherwise you will get a 500 because the second web.config is not allowed to redefine the same section.

Mar 20, 2012 at 6:15 PM
QAmelie wrote:

I have added an image to the view of a content part

<img src="@Url.Content("~/Themes/MyTheme/Content/Images/loading.gif")"/>

The image fails to load with the Url (/Orchard/Themes/MyTheme/Content/Images/loading.gif).  I have checked the image file is in the Images folder.

Previously, I was able to get the image to load with Html.ThemePath but now it requires an extension descriptor and I am not sure how I can supply it a descriptor.

Hi, same thing here, ExtensionDescriptor is a new argument... Do you have this figured out already?

Best regards,

Tiago Silva.

Mar 20, 2012 at 6:40 PM

Hi,

after some research in the source code I found an very useful way to get the current theme and the path!

 

WorkContext.CurrentTheme: Gets the current theme ExtensionDescriptor

Ex.

Html.ThemePath(WorkContext.CurrentTheme, "/Content/Images/SomeImage.png")

 

Have fun.

Best regards,

Tiago Silva.