WooCommerce: Attach media to product
woocommerce_attach_media_to_productAttach existing media library items to a WooCommerce product as the main image or gallery images; choose append to preserve the gallery or replace to rewrite it.
Instructions
[UNIFIED] Attach existing media library items to a WooCommerce product. Use role='main' for the primary image (gallery index 0) or role='gallery' for extra images. mode='append' preserves the existing gallery; mode='replace' wipes and rewrites it.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"site": "<site>",
"product_id": "<product_id>",
"media_ids": "<media_ids>"
},
"name": "woocommerce_attach_media_to_product"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | append | |
| role | No | gallery | |
| site | Yes | ||
| media_ids | Yes | ||
| product_id | Yes |