If you are storing images or files using a “Direct Uploader” field type within a document and you need to retrieve them in your code, you have two options to get this file back:
- Read up on the Kentico API (DocumentHelper.GetAttachment() methods).
- Use Kentico’s “GetFile.aspx” page to reference the file itself.
As much as I would like to do things properly and familiarise myself with the Kentico API in greater detail, project time constraints can be a hindrance. In this case, I used the “GetFile.aspx” page in the following manner:
<img src="/CMSPages/GetFile.aspx?guid=<Attachment GUID>" title="My Kentico Image" />
The GUID for “Attachment GUID” will be found in the document where you use the “Direct Uploader” field.
I don’t know if this is what you would necessarily call a hack. But it works!