Manual:ImportImages.php

importImages.php is a script which imports images to mediawiki from a local directory. Example of invocation:

Invocation
php maintenance/importImages.php /path/to/images/directory png jpg gif bmp PNG JPG GIF BMP Directory recursion is not supported.

Arguments
A list is available in the source of ImportImages.php Imports images and other media files into the wiki USAGE: php importImages.php [options]



Options: --extensions=    Comma-separated list of allowable extensions, defaults to \$wgFileExtensions --overwrite                    Overwrite existing images if a conflicting-named image is found --user=      Set username of uploader, default 'Maintenance script' --comment=       Set upload summary comment, default 'Importing image file' --license=       Use an optional license template

Image import algorithm
1. Make sure that image upload is activated in your wiki.

2. Unpack images tarball to some directory (not to the directory where images should appear in the end) vi@vi-notebook:~/d/wiki/absurdopedia$ tar -xf images.tar vi@vi-notebook:~/d/wiki/absurdopedia$ rm -Rf images/thumb/ 3. Import images using find program and importImages.php script: vi-notebook:/var/lib/mediawiki1.7# find ~vi/d/wiki/absurdopedia/images -type d -exec php maintenance/importImages.php \{\} png jpg jpeg bmp tif gif PNG JPG JPEG BMP TIF GIF \; Import Images

Warning: Invalid argument supplied for foreach in /usr/share/mediawiki1.7/maintenance/importImages.php on line 34 Import Images

Warning: Invalid argument supplied for foreach in /usr/share/mediawiki1.7/maintenance/importImages.php on line 34 Import Images

Saving Coke.jpg...importing...done. JapanOrange.jpg could not be imported; a file with this name exists in the wiki ... 4. Delete unnecessary copy of images: vi@vi-notebook:~/d/wiki/absurdopedia$ rm -Rf images/

Other Examples
Example where it 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

Example of incorrect usage of import: 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. It has failed because of files already existed at their destinations.