How does MediaWiki calculate the file path to an image?

蓝咒 提交于 2019-12-07 01:04:35

问题


I'm just installing MediaWiki (loving it). I'm lookin at this for adding images. I can se the logic of

[[File:MediaWiki:Image sample|50px]]

but where so I set the filepath for "File" (nothing obvious in LocalSettings.php) ... or is there some other logic at work?

I'd appreciate any help Thanks


回答1:


File location is determined by $wgLocalFileRepo which by default depends on $wgUploadDirectory and $wgHashedUploadDirectory. The upload directory defaults to [MediaWiki base dir]/images (Adrian must be using an older version). If hashing is enabled, /x/xy will be appended to the path, where xy are the first two letters of the md5 hash of the filename.




回答2:


The defaults from DefaultSettings.php are:

$wgUploadPath = "$wgScriptPath/uploads";
$wgUploadDirectory = "$IP/uploads";

If you want to change this, you should copy and paste this into LocalSettings.php

And make sure that $wgEnableUploads = true; is in LocalSettings.php too.




回答3:


Your "Image sample" is the name of image, not the name of a file. By config file you can just set the root folder for image uploads.




回答4:


Just for future reference in case someone else runs into this issue:

I installed MediaWiki on my Mac OS Sierra and when I attempted to upload an image I got the following message:

Failed:
Could not open lock file for "mwstore://local-backend/local-public/d/d9/babypicture.png".

I changed the permissions on the mediawiki_root/images folder to be owned by _www user and group.

chown -R _www:_www wiki/images

I was able to upload the image afterward.



来源:https://stackoverflow.com/questions/2813294/how-does-mediawiki-calculate-the-file-path-to-an-image

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!