Image Paths

Posted by Community Admin on 03-Aug-2018 13:43

Image Paths

All Replies

Posted by Community Admin on 14-Dec-2013 00:00

I recently downloaded a template from TornadoApplications, and I noticed that the images were not displaying.  Looking at the HTML I can see that the image paths start with something like "/images/etc" which point to an image library in Sitefinity.  However, when I insert an image from the same library, I get a path something like "localhost:143213/.../etc".  

Rather than updating all the image paths manually, is there a better way to do this?  If I do have to change all the image paths because I'm developing with the inbuilt browser, when I deploy my website will all the paths get updated back to "/images/etc" or will I need to do this manually?

Posted by Community Admin on 14-Dec-2013 00:00

Hi David,

It looks like these templates are using absolute paths?
You should use images like this in your templates:

<asp:Image ID="imgExample" runat="server" ImageUrl="~/Content/Images/Example.jpg" />

Then ASP.NET will figure out how to display the image.

Kind regards,
Daniel

Posted by Community Admin on 14-Dec-2013 00:00

Hi Daniel,

This is how I would do it if I were coding by hand.  But using the ContentBlock editor, I notice when it inserts images it does so with absolute paths.  I would have thought it would prefer relative paths?  My concern is that those without coding experience will simply just add images.  My hope was that Sitefinity would do so appropriately and manage the images and paths.  Perhaps I'm missing a setting for this behaviour?

Posted by Community Admin on 14-Dec-2013 00:00

Hi David,

Sitefinity also adds the ImageId as an attribute of e.g. the image source or href source, so in that case you don't have to worry. Images added manually without this editor or without those ID's would have a problem.

Kind regards,
Daniel

Posted by Community Admin on 14-Dec-2013 00:00

That makes sense, thought it must do something clever.  One less thing to worry about, I'll just change the images and hopefully when I publish to IIS - Sitefinity will do the hard work!   Thanks for your help.

This thread is closed