A way for an editor to browse to an IMG - but dont display img if she does not pick an image

Vote:
 

Hi!

I have a challange here. I want to provide for editors a field to browse to an image. If I use a property and (in Epi admin mode) make it an "Url to Image", Epi just prints the path to the image when the editor publish the page. What is the meaning of that? Why not an img tag with the source attribute?


Ok, so instead I use this method
<img src="<%= CurrentPage["Topic01_IMG01"] %>" alt="" style="width:260px;" />

I make it as an Url to Image property in admin mode, and sure it works. And yes I can provide a way to make an alt text too. But! The problem is this, if the editor doesnt browse to an image the src attribute gets empty and the browser displays a broken image.

So I want the img tag to not be displayed if the editor doesnt browse to an image. How do I do it?

And please, I'am a newbie developer, so be kind and keep it as simple as possible and explain it well. Thank you so much.

I study at home and will attend to the boot camp course.

#52828
Aug 16, 2011 14:15
Vote:
 

I you have a URL to Image and uses the <episerver:property propertyname="Topic01_IMG01" runat="server" />, won't that display the image?

#52829
Aug 16, 2011 14:38
Vote:
 

No I get

<a href="/Global/Bild.png">/Global/Bild.png</a>

    

#52831
Aug 16, 2011 16:29
Vote:
 

if you don't want to do any code behind you can just do

<% if (CurrentPage["propertyname"] != null) { %>
<img src="<%= CurrentPage["propertyname"]" />
<%}%>

#52832
Aug 16, 2011 16:43
Vote:
 

He he, so simple. Ok, thank you very much. I will test it tomorrow, sure it will work.

Oh dear, I really need to study this!

I mark "Mark as answer" tomorrow if it works.

#52833
Aug 16, 2011 16:45
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.