Skip to content

Instantly share code, notes, and snippets.

@cawa-93
cawa-93 / sideloader.function.php
Last active January 12, 2025 21:01 — forked from kellenmace/class-download-remote-image.php
Download and Insert a Remote Image File into the WordPress Media Library
<?php
namespace Plugin\Sideloader;
/**
* Function handles downloading a remote file and inserting it
* into the WP Media Library.
* @param string $url HTTP URL address of a remote file
* @param int $post_id The post ID the media is associated with
* @param string $desc Description of the side-loaded file
* @param string $post_data Post data to override