Send Product Images as Base64

This plugin extends the default WooCommerce API product endpoint by allowing product images to be uploaded using base64-encoded data, instead of image URLs.

This is particularly useful when:

  • images are not publicly accessible via a URL
  • images are generated dynamically
  • you want to avoid external dependencies during product creation

Install the plugin in WordPress

Install the Tinx Media API plugin. If you don't have access to our extension yet, please reach out to our support department: support@tinx-it.nl.

They can provide you with a zip file, which you can then upload as a plugin in WordPress.


Image Handling Modes

With each API request, you can control how images are processed using the image_mode parameter.

Available options:

  • replace (default)
    All existing product images will be removed and replaced with the images provided in the request.
  • append
    The provided images will be added to the existing product images, without removing the current ones.

If the image_mode parameter is not included in the request, the default behavior is replace.


Featured Image

You can define the main (featured) image of the product using the is_featured property.

  • Set "is_featured": true on an image to mark it as the featured image.
  • If multiple images are marked as featured, the last one in the list will be used as the product’s featured image.

Example Request

{
"name": "Test Product with Encoded Images",
"type": "simple",
"regular_price": "29.99",
"description": "Product created with base64 encoded images",
"short_description": "Test product",
"encoded_images": [
{
"data": "{{sample_base64_image}}",
"filename": "product-main.png",
"alt_text": "Product main image",
"caption": "Main product photo",
"description": "Primary product image",
"is_featured": true
},
{
"data": "{{sample_base64_image}}",
"filename": "product-gallery-1.png",
"alt_text": "Gallery image 1"
},
{
"data": "{{sample_base64_image}}",
"filename": "product-gallery-2.png",
"alt_text": "Gallery image 2"
}
],
"image_mode": "replace"
}

Notes

  • Each image must include a valid base64 string in the data field.
  • The filename field is required to correctly store the image.
  • Additional fields such as alt_text, caption, and description are optional but recommended for SEO and accessibility.
  • The first image is not automatically the featured image - this must be explicitly defined using is_featured.