替换 Sitecore 媒体库链接中的空格



当W3C验证我的页面时,我收到以下错误:

Bad value /~/media/Image Libraries/Carousel Images/sea.jpg?w=652&h=263&bc=transparent&as=1&thn=1 for attribute src on element img: Whitespace in path component. Use %20 in place of spaces.

管道中是否有某个地方,或者在渲染这些链接之前对其进行了更改?

编辑:

这是一个示例图片标签:

<img width="257" height="155" src="/~/media/Image Libraries/Section Pods/headphonewoman.jpg?w=257&h=155&bc=transparent&as=1&thn=1" alt="Administration">

这是确切的错误:

Error Line 565, Column 218: Bad value /~/media/Image Libraries/Carousel Images/office.jpg?w=652&h=263&bc=transparent&as=1&thn=1 for attribute src on element img: Whitespace in path component. Use %20 in place of spaces.
…ages/office.jpg?w=652&amp;h=263&amp;bc=transparent&amp;as=1&amp;thn=1" />
Syntax of IRI reference:
    Any URL. For example: /hello, #canvas, or http://example.org/. Characters should be represented in NFC and spaces should be escaped as %20. 

我们还尝试添加覆盖Sitecore.Resources.Media.MediaProvider GetMediaUrl的管道,但这无济于事。

您可以在web.config<encodeNameReplacements>节点下执行此操作:

<encodeNameReplacements>
  // ..
  <replace mode="on" find=" " replaceWith="%20" />
  // ..
</encodeNameReplacements>

最新更新