There is a plugin that will retrieve remote images in the post content and save it in the media library. It is ancient but I tested on 5.5.1 so it is hanging in there 🙂
Unfortunately, you have to open and save each post for it to work. So I created a little plugin that will add a field to the bulk edit interface and trigger the plugin to work on multiple posts.
The one catch is you have to hack the ARI plugin in one teeny place so it will accept a $_REQUEST element rather than just a $_POST. I know. But like I said, this plugin hasn’t been updated in years. So I am ok with doing this one thing. Or, you can just update every single post/page the hard way.
Line 293
//checkbox not checked
-if (!isset($_POST[‘do_remote_archive’])) return $post_id; // Original code
+if (!isset($_REQUEST[‘do_remote_archive’])) return $post_id; // New code
If I find time, I will polish it up and create a pull request on the plugin’s github page. But for now, this works. I highly recommend you deactivate this and the ARI plugin when you’re done archiving. It is designed for a down and dirty time saver. Not a permanent toy.
FYI you need to put in your plugins folder in a folder/file named ‘az-bulk-archive/az-bulk-archive.php’. Then activate it in your plugins list after activating ARI.Â
<?php /* * Plugin Name: Bulk Archive Remote Images * Description: Adds a field to the bulk edit screen to trigger the Archive Remote Images plugin for multiple posts * Author: Amy Hill * Version: 1.0.0 * */ if (!class_exists('az_bulk_archive')){ class az_bulk_archive{ public function __construct() { if ( is_admin() ){ add_action( 'wp_ajax_bulk_edit_append', [$this, 'bulk_edit_append']); add_action('admin_footer', [$this, 'add_js']); } } public function add_js(){ ?> <script> jQuery(document).ready(function($){ $.post( ajaxurl, { 'action': 'bulk_edit_append','data': {}}, function(response){ $('#bulk-title-div').append(response); } ); }); </script> <?php } /***************** * Called via ajax to add the bulk edit fields to the bulk edit screen */ public function bulk_edit_append(){ if (class_exists('ArchiveRemoteImages')){ echo $this->archive_checkbox(); } wp_die(); } /************** * Process bulk edit fields */ public function archive_checkbox(){ // capabilities handled in ARI return '<fieldset class="inline-edit-col gs-bulk">' . '<span class="title">Archive Remote Images </span>' . '<input type="hidden" name="do_remote_archive" value="0"/>' . '<input type="checkbox" name="do_remote_archive" value="1"/>' . '</fieldset>'; } }// end class } $azform = new az_bulk_archive();