简体   繁体   English

如何在MediaWiki扩展中获取图像?

[英]How to get Image in MediaWiki extension?

I'm updating a MediaWiki extension that nicely formats Bibtex extensions ( this one ). 我正在更新一个MediaWiki扩展,该扩展很好地格式化了Bibtex扩展( 这个 )。 One feature is that when a link to a PDF is present then that link gets presented with a PDF icon. 一个功能是,当存在指向PDF的链接时,该链接将带有PDF图标。 This icon is an image uploaded to the wiki as any other file (ie it's not part of the extension itself). 此图标是与其他文件一样上载到Wiki的图像(即,它不是扩展本身的一部分)。 The code then accesses this image like this: 然后,代码按如下方式访问此图像:

$im2 = Image::newFromName("PDF.png");

However, the Image class has been deprecated and removed (I'm using version 1.19). 但是,不推荐使用Image类并删除它(我使用的是1.19版)。 I see that "images" are now "files", but it's unclear to me what the new equivalent of the above is. 我看到“图像”现在是“文件”,但是我不清楚上面所说的新含义是什么。

I could just hard-code the image filename, but that would not be portable to other setups. 我可以对图像文件名进行硬编码,但这不能移植到其他设置中。 I would like to keep this approach of using an image uploaded to the wiki, if possible. 如果可能的话,我想保留使用上传到Wiki的图像的这种方法。

How can I work with files uploaded to a MediaWiki through the MediaWiki API? 如何处理通过MediaWiki API上传到MediaWiki的文件?

看起来wfFindFile函数现在可以这样做:

$im2 = wfFindFile("PDF.png");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM