Developers
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Certified Developer

Absolute Path for image asset

Hello Team,

How do we get the absolute path for an image from the crownpeak relative path of an image asset.

current path : /Site/cpt_internal/0424

Absolute path : https://www.website.com/images/logo/logo-3-color.png

Thanks,

Basavaraj

0 Kudos
2 Replies
Highlighted
Partner Enablement
Partner Enablement

Re: Absolute Path for image asset

The best approach is to use the Util.ReplaceCptInternals method.

Assuming you have a field with the image reference, the code should look something like this:

var imgageLink = Util.ReplaceCptInternals(asset["image_field"], addDomain: true, protocolType: ProtocolType.Https);

You shouldn't need to do this in the output handlers (output.aspx) as the DXM publishing engine will take care of this itself. However, if you need this link in some other context, typically a Search G2 handler, then you will need to call this method.

0 Kudos
Highlighted
Certified Developer

Re: Absolute Path for image asset

Thank you Marcus for you quick response.

 

But I am looking something which provide the asset path (image path should access for the public) .

we are creating the JSON for mobile application where they can access the content and assets, but we are facing the deficuties to get the full url which is accessed publicaly. I implemented with whatever you suggested but that is giving me .asp file. hope you understand my concen.

 

thanks,

Basavaraj

0 Kudos