Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Can I use image as a hyperlink in Kentico? View modes: 
User avatar
Member
Member
steven4733-gmail - 1/24/2012 2:13:34 PM
   
Can I use image as a hyperlink in Kentico?
in a document type I set one image field as file type, and user could upload their images by using a selector. In transmission I use <%# GetImage("Image") %> to display the image that they uploaded. However, I found if I add <a> markup in the transmission, the image won't display. I check the souce code of output page, it is
<a href='http://www.google.com'><img alt="" src="/getattachment/e0bfceee-a334-4e18-8ecb-ccd68c7ad9e1/New-document.aspx" /></a>

The image just doesn't show, but if I remove <a> markup, which the output source code is
<img alt="" src="/getattachment/e0bfceee-a334-4e18-8ecb-ccd68c7ad9e1/New-document.aspx" />

The image shows. Does anyone know the reason?

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 1/25/2012 3:03:26 AM
   
RE:Can I use image as a hyperlink in Kentico?
Hi,

When editing the transformation, at the bottom there is a link to a transformation functions help. There you can see that the output of GetImage function is a complete HTML code of an image - it means the IMG tag.

If you want to have the URL link, you should use the GetFileUrl function instead or together with the above function.


Best regards,
Juraj Ondrus

User avatar
Member
Member
steven4733-gmail - 1/25/2012 8:46:36 AM
   
RE:Can I use image as a hyperlink in Kentico?
Hi Juraj,

Thank you for your reply, I think you might misunderstand my question here. I know how to display the uploaded image, just whenever I add <a> markup, it doesn't show. I modified my transmission code as following:
<a href="<%# Eval("Link") %>"><img src="<%# GetFileUrl("Image") %>" Title="<%# Eval("Title") %>" /></a>


"Link" is the url field, "Image" is the uploaded image field, "Title" is a text field. The problem is the image does not show, however, when I remove <a> markup, images show up.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 1/26/2012 2:07:10 AM
   
RE:Can I use image as a hyperlink in Kentico?
Hi,

and what is the rendered HTML code? Is it OK?

I am using this:
<a href=<%#GetDocumentUrl()%>><%# GetImage("FileField") %></a>

Or, whatever in the "href" parameter - absolute, relative URL, etc.

And it is working just fine.

Best regards,
Juraj Ondrus