Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Alt tags on file upload View modes: 
User avatar
Member
Member
Jon White - 9/11/2013 5:32:44 AM
   
Alt tags on file upload
Hi there

I'm using document types to update staff biographies, I've set a field to upload a staff image using the file upload.

How do I set the alt tag for this, as there is no option?, should i be using another type of upload system?

I've tried several upload types but none allow me to input alt tags.

Am I missing something here?

Alternatively maybe i could just add a field below file upload to input the alt tag, and then code transformation to add it into displayed image code, how would i do that?

My code to gather the image is here:

<%# IfEmpty(Eval("MainImage"), "", GetImage("MainImage")) %>

Surely i'd need to put in something like "alt=<%# Eval("alt") %>? Am i correct, i just don't know what to put and where to make it part of the image src code section?

Thanks in advance

Jon

User avatar
Kentico Support
Kentico Support
kentico_filipl - 9/12/2013 2:49:02 AM
   
RE:Alt tags on file upload
Hi Jon,

I would recommend that you use Image selection form control for instance instead of Upload file because it enables you to retrieve the image using <img> tag for which you can also set alt attribute. Then you to modify your transformation function so that it looks like the following:
<img src="~/CMSPages/GetFile.aspx?nodeguid=<%# Eval("MainImage") %>" alt="<%# Eval("alt") %>" />

Best regards,
Filip Ligac

User avatar
Member
Member
Jon White - 9/12/2013 4:13:19 AM
   
RE:Alt tags on file upload
Hi Filip,

That's great it works! although if I don't have an image it shows a little 'image not found icon', how would I make the code above show nothing if there is no image.

I was using this:

<%# IfEmpty(Eval("MainImage"), "", GetImage("MainImage")) %>

but I don't know how to mix the two.

Thanks
Jon

User avatar
Kentico Support
Kentico Support
kentico_filipl - 9/13/2013 8:38:39 AM
   
RE:Alt tags on file upload
Hi Jon,

Using IfEmpty combined with retrieving image from Image selection form control should look like this:
<%# IfEmpty(Eval("MainImage"), "", "<img src=\"" + (GetDocumentUrl("MainImage", "")) + "\" alt=\"" + (Eval("alt")) + "\" />") %>

Best regards,
Filip Ligac