GithubHelp home page GithubHelp logo

isabella232 / newspack-post-image-downloader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from automattic/newspack-post-image-downloader

0.0 0.0 0.0 111 KB

Downloads all the images in Posts which are hosted externally, or imports them directly from local files.

License: GNU General Public License v2.0

Shell 12.02% PHP 87.98%

newspack-post-image-downloader's Introduction

Newspack Post Image Downloader

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.

Features

The plugin features CLI commands with parameters which offer a flexible set of basic features.

-- download or import images from local files

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.

-- download images from specific hosts only

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).

-- skip (exclude) specific hosts from downloading

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.

-- parallel downloading

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.

-- downloads absolute or relative referenced URIs

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.

-- custom post type and post status selection

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.

-- download images for specific Posts only

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.

-- error logging

Creates detailed custom error logs for review afterwards.

-- dry-run

You may simulate and run the command without actual downloads or changes to your content by using the --dry-run flag.

How to install

Run composer install.

List of all available commands and parameters.

Can be found here.

Caveats

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 );

newspack-post-image-downloader's People

Contributors

iuravic avatar miguelpeixe avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.