Manual:importImages.php
| MediaWiki File: importImages.php | |
|---|---|
| Location: | /maintenance/ |
| Source code: | |
| Classes: | None |
importImages.php is a script which uploads images to mediawiki from your computer.
Contents |
[edit] Example
php maintenance/importImages.php /path/to/images/directory png jpg gif bmp PNG JPG GIF BMP
Importimages.php will not search and upload images in sub-directories (directory recursion)
What a successful import of one image, Lance2.jpg looks like in windows:
| root@f345:/home/t/public_html/deadrisingwiki.com/public/w/maintenance# php importImages.php /home/t/public_html gif bmp PNG JPG GIF BMP
Import Images Importing Lance2.jpg...done. Found: 1 Added: 1 root@f345:/home/t/public_html/deadrisingwiki.com/public/w/maintenance# |
[edit] Arguments
A list of available commands can be found inside ImportImages.php beginning on line 290:
Imports images and other media files into the wiki
USAGE: php importImages.php [options] <dir>
<dir> : Path to the directory containing images to be imported
Options:
--extensions=<exts> Comma-separated list of allowable extensions, defaults to $wgFileExtensions
--overwrite Overwrite existing images with the same name (default is to skip them)
--limit=<num> Limit the number of images to process. Ignored or skipped images are not counted.
--from=<name> Ignore all files until the one with the given name. Useful for resuming
aborted imports. <name> should be the file's canonical database form.
--skip-dupes Skip images that were already uploaded under a different name (check SHA1)
--sleep=<sec> Sleep between files. Useful mostly for debugging.
--user=<username> Set username of uploader, default 'Maintenance script'
--check-userblock Check if the user got blocked during import.
--comment=<text> Set upload summary comment, default 'Importing image file'.
--comment-file=<file> Set upload summary comment to the content of <file>.
--comment-ext=<ext> Causes the comment for each file to be loaded from a file with the same name
but the extension <ext>. If a global comment is also given, it is appended.
--license=<code> Use an optional license template
--dry Dry run, don't import anything
--protect=<protect> Specify the protect value (autoconfirmed,sysop)
--unprotect Unprotects all uploaded images
Note: "--comment-ext" defines a file extension like ".meta" that contains the file comment, i.e. the content of the wiki-metadata-page associated with each imported file. The value of --comment-ext must include the leading dot. The associated file is searched both as appended and substituted extension. Thus, importing x.jpg and setting "--comment-ext .meta" either of x.meta or x.jpg.meta may contain the file comment.
[edit] Common error messages
[edit] Does not find the picture to upload
Example where the script doesn't find any picture to upload:
vi-notebook:/var/lib/mediawiki1.7# php maintenance/importImages.php /store/wiki/absurd_pic jpg Import Images Warning: Invalid argument supplied for foreach() in /usr/share/mediawiki1.7/maintenance/importImages.php on line 34
Incorrect folder path
t@f66677:~/public_html/dead.com/public/w/maintenance$ php importImages.php /m gif bmp PNG JPG GIF BMP Import Images No suitable files could be found for import.
Usually this is because the path to the folder is incorrect.
[edit] Upload failed error
The following error can be caused by two issues:
- chmod permissions needs to be changed, and/or
- user does not have the privileges to upload the pictures
vi-notebook:/var/lib/mediawiki1.7# php maintenance/importImages.php /store/wiki/absurd_pic/0/00 jpg Import Images Saving Coke.jpg...failed. Saving JapanOrange.jpg...failed. Saving Friki.JPG...failed.
Problem 1: chmod permissions needs to be changed
- Solution: Change chmod settings
- chmod three folders:
- images/temp,
- images/thumb and
- images/archive to 777
- If it hasn't already been done, in LocalSettings.php, uncomment the line
$wgHashedUploadDirectory = false;by adding # in front of the line.
Problem 2: user does not have the privileges to upload the pictures
- Solution: switch users or change user privileges
[edit] Skipping existing pictures
By default, ImportImages.php will not overwrite pictures. If a picture with the same name already exists on the wiki, you will get this error:
php importImages.php /home gif bmp PNG JPG GIF BMP Import Images Dadtest.jpg exists, skipping Found: 1 Skipped: 1
To overwrite any images type:
php importImages.php /home gif bmp PNG JPG GIF BMP --overwrite
The result will be:
Import Images Dadtest.jpg exists, overwriting...done. Found: 1 Overwritten: 1
[edit] See also
- Extension:SpecialUploadLocal
- Manual:ImportDump.php - for importing pages
- Manual:DumpBackup.php - for exporting pages