Skip to content

Instantly share code, notes, and snippets.

View buraksahin59's full-sized avatar
:atom:
React Native

Burak buraksahin59

:atom:
React Native
View GitHub Profile
@buraksahin59
buraksahin59 / rs_upload_from_url.php
Created August 11, 2023 12:18 — forked from RadGH/rs_upload_from_url.php
Upload a file from a URL to the WordPress media gallery. Supports images, PDFs, and other file types.
<?php
/**
* This function uploads from a URL.
* To upload from a local file path instead
* @see: https://gist.github.com/RadGH/3b544c827193927d1772
*
* Example usage: Upload photo from URL, display the attachment as as html <img>
* $attachment_id = rs_upload_from_url( "http://example.com/images/photo.png" );
* echo wp_get_attachment_image( $attachment_id, 'large' );