0

I've tried over ten various methods of referencing in image within a view (Please don't ask why I'm doing it this way). Anyway obviously one of the biggest problems is that I can never escape the route, even specifying http://localhost:2324:/x/y/img.jpg is pointless.

Is there actually a way referencing an image simply via using file paths?

edit: Pretty sure you can escape the root, Here's an example:

<%= ("<img src=”../../vehicleimages/" + Model.vehicleid + ".jpg”  width=“250“ height=“300“ />")%>

The result of this would be:

<img src=”../../vehicleimages/b480b00e-c725-40fe-a5c2-277e82c5b1d9.jpg”  width=“250“ height=“300“ />

All good, however if I click the link within browser source code, it sends me to the following:

http://localhost:4716/vehicle/details/vehicleimages/b480b00e-c725-40fe-a5c2-277e82c5b1d9.jpg%E2%80%9D

I want http://localhost:4716/vehicleimages/b480b00e-c725-40fe-a5c2277e82c5b1d9.jpg

3
  • 1
    I think the question is a bit unclear...but sounds interesting! Could you try and add more information about what exactly you are trying to achieve? Commented May 6, 2011 at 7:59
  • Maybe post some example code of what you've tried already... Commented May 6, 2011 at 8:02
  • That trailing %E2%80%9D translates into ” - it seems you are using the wrong type of qoutation marks in your src attribute. Commented May 6, 2011 at 8:15

1 Answer 1

2

I think it's your quotation marks that messes things up. Instead of:

<%= ("<img src=”../../vehicleimages/" + Model.vehicleid + ".jpg”  width=“250“ height=“300“ />")%>

...try either:

<img src="../../vehicleimages/<%= Model.vehicleid %>.jpg" width="250" height="300" />

...or:

<%= ("<img src=\"../../vehicleimages/" + Model.vehicleid + ".jpg\" width=\"250\" height=\"300\" />") %>
Sign up to request clarification or add additional context in comments.

1 Comment

Never thought about embedding another tag to include the variable, hah cheers mate, working perfectly

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.