1

I am running Kentico 12.0.24 MVC and there is an issue how the inserted images render using the text editor.

When inserting images using the Text editor in Kentico CMS, I am able to see the inserted images inside the Text Editor, but when viewing on the front-end page the images do not render and this is due to how the image path is generated with a leading ~ (tilde) character.

The generated image path is relative, which is fine but is the leading tile that breaks it.

Here are the steps to reproduce this:
1. In Kentico CMS, go to a page that has a Rich text editor (WYSIWYG).
2. In the text editor, click on the button called "Insert/Edit image or media".
3. In the popup window, click on the tab called "Media Libraries".
4. From the list, I select an image. At this point, the URL image URL preview will be as follow "/Admin/IPGLaserSystems/media/Random/application-non-contact-1x.jpg".
5. I click on "Save & Close", I am able to see the image inserted in the text editor.
6. Click "Save" at the top.
7. I navigate to the page and the image goes not show and at this point the generated image path is as follow "~/IPGLaserSystems/media/Random/application-non-contact-1x.jpg".

If the tilde character is removed from the path, then it renders the image fine. This should work natively.

I also found the following article, that seems to address the insertion of links from text-editor in relative form, but doesn't seems to directly address the issue with using relative (tilde-based) links in general: https://devnet.kentico.com/articles/how-to-fix-links-inserted-via-a-wysiwig-editor-in-kentico-12

Please advise, thank you.

4

1 回答 1

6

您可以像这样访问它们。假设您有一个item带有 property的模型image。在您的视图中,您可以像这样访问它

@Html.Kentico().ResolveUrls(item.image)

看看这是否有效。我总是用这个。这样做的好处是,假设你有一个所见即所得的区域,里面有很多图像。例如,您有一个item具有属性的模型textarea。在您的视图上使用这样的表达式将解析所见即所得区域中的所有图像。

@Html.Kentico().ResolveUrls(item.TextArea)
于 2019-06-11T16:10:07.157 回答