Skip to content

Instantly share code, notes, and snippets.

View NickMkrtchyan's full-sized avatar
🏠
Working from home

Nick Mkrtchyan NickMkrtchyan

🏠
Working from home
  • WeBuild Holding LLC
  • Russia / St. Petersburg
View GitHub Profile
@NickMkrtchyan
NickMkrtchyan / wordpress-upload-base64.php
Created January 15, 2024 02:11 — forked from cyberwani/wordpress-upload-base64.php
Upload a base64 string as image to the WordPress media library
<?php
/**
* Save the image on the server.
*/
function save_image( $base64_img, $title ) {
// Upload dir.
$upload_dir = wp_upload_dir();
$upload_path = str_replace( '/', DIRECTORY_SEPARATOR, $upload_dir['path'] ) . DIRECTORY_SEPARATOR;