Downloads all the images in Posts which are hosted externally, or imports them directly from local files.
GPL-2.0 License
This plugin is a content migration service tool. It imports externally hosted images found in your Post contents.
A typical use case for downloading and importing external images, is to aid importing of all the contents after the site's migration from one host to another.
The plugin can first attempt to import the images from local files, if you have them available as local files, or if not, it will download and import them from the source URL.
The plugin features CLI commands with parameters which offer a flexible set of basic features.
If you have images available in your local files, and you use the --folder-local-images
parameter, the plugin will first attempt to import these directly, without downloading them.
The plugin downloads all the externally hosted images by default. Optionally, we can set to download just from specific hosts.
There is a helper command called scan-existing-images-hostnames
which lists all the host names used in images. After listing all existing hosts, we can chose to download just from specific ones (via the --only-download-from-hosts
command parameter).
Also optional. Alternatively, you can specify hosts not to download images from, and the plugin will download images from all the hosts except these, e.g. *.google.*
(the --exclude-hosts
parameter). Wildcards are also supported to use all domain extensions and/or subdomains.
To speed up downloading, you could even run several commands in parallel by splitting and grouping your Post IDs into several batches, and then running the command with different --post-id-from
and --post-id-to
ID ranges, or with a specific --post-ids-csv
.
Besides downloading images from fully qualified/absolute URLs, e.g. https://host.com/img.jpg
, the plugin can download relative URLs if you provide the CLI param --default-image-host-and-schema=https://example-host.com
.
By default, the Plugin downloads or imports external images from all the public Posts and Pages, and this can be customized with --post-types
and --post-statuses
.
You can specify a list of Post IDs by using the --post-ids-csv
or an ID range --post-id-from
abd --post-id-to
.
Creates detailed custom error logs for review afterwards.
You may simulate and run the command without actual downloads or changes to your content by using the --dry-run
flag.
Run composer install
.
Can be found here.
A fresh WordPress site supports importing a number of image formats. In case of different formats, you may find this error in your logs:
Sorry, this file type is not permitted for security reasons.
In this case, you can additionally use the upload_mimes
WP hook to temporarily or permanently permit additional formats.
Or even (temporarily) set the following constant in your wp-config.php
define( 'ALLOW_UNFILTERED_UPLOADS', true );