+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Image Paths

Image Paths

5 posts, 0 answered
  1. David
    David avatar
    114 posts
    Registered:
    19 Jul 2012
    14 Dec 2013
    Link to this post
    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 "http://localhost:143213/images/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?
  2. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    14 Dec 2013
    Link to this post
    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
  3. David
    David avatar
    114 posts
    Registered:
    19 Jul 2012
    14 Dec 2013 in reply to Daniel Plomp
    Link to this post
    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?
  4. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    14 Dec 2013 in reply to David
    Link to this post
    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
  5. David
    David avatar
    114 posts
    Registered:
    19 Jul 2012
    14 Dec 2013 in reply to Daniel Plomp
    Link to this post
    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.
5 posts, 0 answered