我想在mediawiki中找到图像的确切URL,以发送我的pinterest代码。要查找页面URL,我使用urlencode($ wgTitle-> getFullURL()),但我无法弄清楚用于图像和图像描述的代码。谢谢
要在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。
getFullUrl()
method
有关详细信息,请参见getFullUrl()
类和File
类文档。
您可以链接到页面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