URL of Attachment Icon

Justin Hugelen-Padin asked on December 22, 2014 17:07

Hello,

I'm trying to get the url of an attachment icon in a transformation. In Kentico 7 I previously used GetAttachmentIconUrl(Eval("AttachmentExtension"), "List"), however in Kentico 8 this has been deprecated and I can't seem to get GetAttachmentIcon to work. Any suggestions on how I can get the attachment icon url?

Thanks! Justin

Correct Answer

Ankit Agrawal answered on December 23, 2014 09:10

May be nested double quotes are causing the causing the problem, can you try, please note I have changed some of double quotes to single quotes.

<img src='<%# GetAttachmentIcon("AttachmentGUID") %>' alt='<%# Eval("AttachmentName",true) %>' />

0 votesVote for this answer Unmark Correct answer

Recent Answers


Timothy Fenton answered on December 22, 2014 17:30

Hello Justin!

If you are just trying to display the icon of an attachment GetAttachmentIcon is the proper method to use. Could you check your source and see if it is generating something like:

<i aria-hidden="true" class="icon-file-doc icon-file-default">

Thanks

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on December 22, 2014 17:41

Check out the API changes documentation. It shows in there the slight changes for this method. Should help resolve your issue.

0 votesVote for this answer Mark as a Correct answer

Justin Hugelen-Padin answered on December 22, 2014 17:47

Timothy,

I don't know why I didn't check it before, but the html is getting all mangled. This is the output that I'm getting:

<img class="icon-file-pdf icon-file-default" true"="" src="<i aria-hidden="> " alt="Kiswahilil-milk-quality-guide-A4.pdf" />

This is my code: <img src="<%# GetAttachmentIcon("AttachmentGUID") %>" alt="<%# Eval("AttachmentName",true) %>" />

0 votesVote for this answer Mark as a Correct answer

Timothy Fenton answered on December 22, 2014 17:56

Thank you for that Justin,

try just using <%# GetAttachmentIcon("AttachmentGUID") %> without putting it in the img tag. GetAttachmentIcon is now CSS-based so it will need to be handled ( if it isn't already ) within a css file!

Hope this helps

1 votesVote for this answer Mark as a Correct answer

Justin Hugelen-Padin answered on December 22, 2014 19:32

I took it out of the img tag and the output is: <i aria-hidden="true" class="icon-file-pdf icon-file-default">

Still not showing up. Where is it referencing the pdf icon from?

0 votesVote for this answer Mark as a Correct answer

Timothy Fenton answered on December 22, 2014 19:38

It is referencing the icon-file-pdf in ~/App_Themes/Global/Skin.css

0 votesVote for this answer Mark as a Correct answer

American Technology Services, Inc. American Technology Services, Inc. answered on December 22, 2014 20:17

Can't seem to locate it, but I'll do some more research a little later and update this thread with my results. Thanks for the help!

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.