如何在MediaWiki中查找图像路径?

问题描述 投票:2回答:3

我想在mediawiki中找到图像的确切URL,以发送我的pinterest代码。要查找页面URL,我使用urlencode($ wgTitle-> getFullURL()),但我无法弄清楚用于图像和图像描述的代码。谢谢

mediawiki
3个回答
2
投票

要在Wiki页面中获取文件路径,可以使用[[Special:Filepath]][[Special:Filepath]]或指向{{filepath:...}} parser function的链接。

[要通过PHP以编程方式获取它,您可能想看看{{filepath:...}}Media namespace

Media

([How does MediaWiki calculate the file path to an image?类中的code of the filepath function

对于您的用例,您也可以看看$file = wfFindFile( $filename ); $url = $file->getFullUrl(); ,他们也计划支持Pinterest。


1
投票
getFullUrl() method

有关详细信息,请参见getFullUrl()类和File类文档。


0
投票

您可以链接到页面Extension:AddThis$f = wfFindFile( 'Foo.jpg' ); $imageUrl = $f->getCanonicalUrl(); // http://mywiki.com/images/0/06/Foo.jpg $descriptionPage = $f->getTitle()->getFullUrl(); // http://mywiki.com/wiki/File.jpg ,该页面会将请求重定向到完整图像位置,例如:File重定向到完整图像路径Title

© www.soinside.com 2019 - 2024. All rights reserved.