Kentico Text Area - Relative URLs for Images

Leif Anderson asked on January 18, 2024 00:07

We are using Kentico 13 with MVC websites that consume the data. Our marketing team occasionally attaches images into rich text areas, and they have a relative URL to Kentico (like: <img src="/getmedia/guid/filename.png" />). However, when this gets rendered on our main website, it'll be a bad reference (because the relative URL is trying to be relative to our MVC website.

I tried just changing the image URL to include the fully-qualified url (ie: <img src="https://cms.website.com/getmedia/guid/filename.png" />, but Kentico changes it back to a relative URL when I save. How do I stop it from doing that?

Correct Answer

Leif Anderson answered on January 19, 2024 20:22

This turns out that it was actually working fine, but just that static URLs in text fields weren't working because of a recent Kentico 13 upgrade. The URLs changed from something like /getattachment/Insights/SI-Group/ULTRANOX-626-Antioxidant-Food-Packaging/Text-Area/spacer-SIGROUP-1.png.aspx" to /getattachment/c27f0a2b-07fc-47b6-a13a-decc361cfbac/spacer-SIGROUP-1.png?lang=en-US. When we just updated this, it may have been cached or something, because it wasn't working... so, we assumed we needed "cms.chempoint.com" in the URL to make it work. But turns out, that Kentico just does this for us on the front-end (where both the cms URL and MVC site URL both work to render the image). So, thanks, Juraj for promping us in that direction!

Here's how we were updating - through the WYSIWYG Editor: Image Text

And then here's what the code outputs: <img alt="spacer-SIGROUP-1.png" src="/getattachment/c27f0a2b-07fc-47b6-a13a-decc361cfbac/spacer-SIGROUP-1.png?lang=en-US" title="spacer-SIGROUP-1.png" />

And, when we consume this field with the relative URL on the front-end (website/presentation URL: www.chempoint.com), i thought the URL was incorrect (with www.chempoint.com), but that actually worked fine:

This works: https://cms.chempoint.com/getattachment/c27f0a2b-07fc-47b6-a13a-decc361cfbac/spacer-SIGROUP-1.png?lang=en-US

This also works: https://www.chempoint.com/getattachment/c27f0a2b-07fc-47b6-a13a-decc361cfbac/spacer-SIGROUP-1.png?lang=en-US

0 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on January 18, 2024 00:26 (last edited on January 18, 2024 00:28)

The URL needs to include the domain the image is on. So if your Kentico MVC website is at mvcwebsite.com and the images work there without issue, then you need to prepend mvcwebsite.com to that relative path.

There will most likely be a config setting in the Frola editor settings to not automatically fix that.

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on January 18, 2024 05:35

How exactly are they entering the images? Are they using the default selector? What is set as the Presentation URL for the site?

0 votesVote for this answer Mark as a Correct answer

Leo Rockswold answered on January 18, 2024 16:28

Does anyone know where this setting is? I have not been able to find it.

I am experiencing the same issue.

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on January 19, 2024 06:02

Could you please provide detailed and step by step instructions what exactly you mean, how the links are being entered and how to reproduce this issue using the out of the box Kentico installation with the sample Dancing Goat project? When I am using the selector, then in the admin app the links are the preview links - which is expected and OK. Then, on the live site are these links transformed correctly and everything works fine.

0 votesVote for this answer Mark as a Correct answer

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