Skip to content

Instantly share code, notes, and snippets.

@nikkyandrei
nikkyandrei / woocomerce_rest_api_upload_image_base64.php
Last active January 17, 2024 14:03
woocomerce_rest_api_upload_image_base64.php
<?php
// this is only a part of it
namespace DLS_WC_REST;
class Products extends \WC_REST_Products_Controller {
protected $namespace = 'wc/v3';
<?php
// just to insert in my class
trait WpUploadBase64 {
public function uploadImage($base64_img, $title, $max_size = []) {
// option to resize image - will save space on host usualy don't need image more than 1920 x 1080
// read more information on crop = false, true , [center|left|right,center|top|bottom ] :
// https://developer.wordpress.org/reference/functions/image_resize_dimensions/
// https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/resize/