Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Saied 349 posts 674 karma points
    Sep 17, 2015 @ 01:32
    Saied
    0

    Resolve image paths for directory in visual studio?

    In the root of my website, I have an images folder that I created in visual studio. In my backoffice, I have the a root node (Home) and underneath home, I have a Support node.

    If I load templates (views) into the home node, the images come up fine if I use @Url.Content('...'), but underneath Support, I have another node called request and if I put images on this template, no images show. When I inspect the images source, instead of it pointing to /images/xyz.png, it is pointing to /support/images/xyz.png when I go to the request page.

    How can I resolve these images?

    Should I store the images in the media section? Would this make it easier to resolve or is my custom folder just fine?

    Thanks, Saied

  • Steve Morgan 1349 posts 4459 karma points c-trib
    Sep 17, 2015 @ 09:24
    Steve Morgan
    0

    Hi,

    Not sure I'd ever use virtual directories with Umbraco anyhow but include a tilda to ensure it resolves up.

    @Url.Content("~/images/icons/email.png")
    

    There's some info here on using this - I tend to just hardcode my references :) http://stackoverflow.com/questions/10468987/why-should-i-use-url-content-blah-blah-blah

  • Saied 349 posts 674 karma points
    Sep 17, 2015 @ 11:23
    Saied
    0

    Hi Steve,

    Sorry, I should have given a better example. I am using the ~ character like in your example, but when I created the Support node in Umbraco, going up one level from Request (node that lives under Support) goes up to Support which does not exist in VS and looks for the images there?

    That is what I am struggling with?

    Thanks

  • Steve Morgan 1349 posts 4459 karma points c-trib
    Sep 17, 2015 @ 12:24
    Steve Morgan
    0

    So your site structure is something like:

    Home

    • Support
      • Request

    In your template you have something like:

    <h1>@Url.Content("~/images/icons/email.png")</h1> 
    <img src="@Url.Content("~/images/icons/email.png")" />
    

    I've tested this in both the Master template and in specific templates (rendered as children). It resolves correctly under two levels. Have you got a hardcoded string inside the Url.Content() like mine or are you using a picker? Can you paste the code?

    There used to be a setting in IIS where you can turn off Parent Paths but I thought this was only classic ASP - have you got this on (though not sure how you'd do this in VS!?

  • Saied 349 posts 674 karma points
    Sep 17, 2015 @ 13:40
    Saied
    0

    Hi Steve,

    I feel like I have wasted your time, sorry about that. I realized the problem. I was doing everything right, but for some reason when I made the change in visual studio to my template, it would not reflect in the back office when I refreshed the website, so in a nutshell, everything is working as expected.

    Thanks again, Saied

  • Steve Morgan 1349 posts 4459 karma points c-trib
    Sep 17, 2015 @ 12:25
Please Sign in or register to post replies

Write your reply to:

Draft