How does MediaWiki calculate the file path to an i

2019-04-24 14:50发布

问题:

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.