无论如何允许在 mediawiki 中使用 base64 编码的图像?

发布于 2025-01-02 17:53:28 字数 808 浏览 4 评论 0原文

我正在使用 mediawiki 1.17,所以我尝试了以下两种方式:

$wgAllowImageTag = true;
$wgRawHtml = true; #I know it's insecure just wanted to see if it'd work

我的 img 标签形式:

<img src="data:image/gif;base64,R0lGODlhDwAPAKECAAAAzMzM/////
wAAACwAAAAADwAPAAACIISPeQHsrZ5ModrLlN48CXF8m2iQ3YmmKqVlRtW4ML
wWACH+H09wdGltaXplZCBieSBVbGVhZCBTbWFydFNhdmVyIQAAOw=="
alt="Base64 encoded image" width="150" height="150"/>

呈现为:

<img alt="Base64 encoded image" width="150" height="150" />

如果我编辑页面,img 标签仍然包含所有数据。

背景

我正在从 CRM 系统 (sugarcrm) 导出 kb 文章。 Sugar 对链接到每篇知识库文章的图像进行 Base64 编码。这使得将这些图像同步到 mediawiki 站点变得非常方便,而无需导出/重新链接图像。因此,如果我能让 mediawiki 允许使用 base64 编码的图像,那就太好了。就我而言,我们的 mediawiki 网站不是由公众编辑的,而是由我们公司的成员编辑的。

I'm using mediawiki 1.17 so I tried both:

$wgAllowImageTag = true;
$wgRawHtml = true; #I know it's insecure just wanted to see if it'd work

My img tags of the form:

<img src="data:image/gif;base64,R0lGODlhDwAPAKECAAAAzMzM/////
wAAACwAAAAADwAPAAACIISPeQHsrZ5ModrLlN48CXF8m2iQ3YmmKqVlRtW4ML
wWACH+H09wdGltaXplZCBieSBVbGVhZCBTbWFydFNhdmVyIQAAOw=="
alt="Base64 encoded image" width="150" height="150"/>

Are getting rendered as:

<img alt="Base64 encoded image" width="150" height="150" />

If i edit the page, the img tag still has all the data.

Background

I'm exporting kb articles from my CRM system (sugarcrm). Sugar encodes the images linked to each KB article in base64. This makes it pretty convenient for syncing those images to the mediawiki site without having to export / relink images. So, would be great if I could get mediawiki to allow the base64 encoded images. In my case our mediawiki site is not edited by the general public, just members of our company.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

紙鸢 2025-01-09 17:53:28

您是否打开了 $wgAllowExternalImages = true;

我知道从技术上讲这不是一个外部图像,但也许 mediawiki 也这么对待它。您还可以尝试将其列入白名单

Did you turn on $wgAllowExternalImages = true;

I know technically it isn't an external image, but maybe mediawiki is treating it as such. You could also try whitelisting it.

肤浅与狂妄 2025-01-09 17:53:28

虽然您不太可能仍然需要这个,但它可能会对其他人有所帮助:我刚刚创建了一些补丁说明以使 MediaWiki(以及基于 CKeditor 的 WYSIWYG 扩展)支持 base64 图像。

https://github.com/limasierra/MediaWiki-Base64-patch

hth

Although it's unlikely that you still need this, it may help others: I just created some patch instructions to make MediaWiki (and the CKeditor-based WYSIWYG extension) support base64 images.

https://github.com/limasierra/MediaWiki-Base64-patch

hth

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文