I need to reference an image in my code, from two different pages (with different paths to /images)

StackOverflow https://stackoverflow.com/questions/3765614

Question

So, I have a function:

public string genSomeHtml(){
   //Gen some html including and image called foobar.gif
}

Now, I want to call genSomeHtml() from two different pages, but they have different paths to /images. So, I can't exactly use "../../images/foobar.gif" and I'd rather not pass a param to tell me where to look. Afterall, the calling page shouldn't care about how the html is rendered, it just needs to work.

any ideas?

Was it helpful?

Solution

General answer: Output your image with an absolute uri, instead of relative. so <img src="images/myphoto.jpg"> becomes <img src="http://localhost/images/myphoto.jpg">

If that wasn't the right answer, please rephrase your question and add examples.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top