Michelle
Michelle

Reputation: 249

Kentico - Get absolute (full) url of image from custom page type

I have a custom page type for infographics with an "Image" field to select item from media library. I'd like to get the absolute URL of the Image in a transformation for RSS feed. The code below only generates the relative URL. I've tried adding GetAbsoluteUrl() in different ways but couldn't make it to work. Could you help? Thanks!

<description><%# EvalCDATA("Image") %></description>

Upvotes: 0

Views: 1445

Answers (2)

Kristian Bortnik
Kristian Bortnik

Reputation: 838

I'm not sure if it makes sense to just put the image URL inside the <description>. If this is what you really need, getting an absolute URL would look like this:

<description><%# GetAbsoluteUrl(Eval<string>("Image")) %></description>

If you want an image tag (wrapped in a CDATA tag), you can do the following:

<description><![CDATA[<img src="<%# GetAbsoluteUrl(Eval<string>("Image")) %>" />]]></description>

Upvotes: 1

Peter Mogilnitski
Peter Mogilnitski

Reputation: 998

Take a look at Transformation methods

<%# GetAbsoluteUrl(EvalCDATA("Image")) %>

or if this is an attachment, i.e. GUID

<%# GetFileUrl("Image") %>

Upvotes: 0

Related Questions