Good morning
I am trying to implement a code to be able to send to my application in the rest API of my custom type the slug of the image with the size 300x that wordpress generates. How can I do it?
In woocommerce i have this code, but i dont know customize to custom fields in toolset
function prepare_product_images($response, $post, $request) {
global $_wp_additional_image_sizes;
if (empty($response->data)) {
return $response;
}
foreach ($response->data['images'] as $key => $image) {
$image_urls = [];
foreach ($_wp_additional_image_sizes as $size => $value) {
$image_info = wp_get_attachment_image_src($image['id'], $size);
$response->data['images'][$key][$size] = $image_info[0];
}
}
return $response;
}
add_filter("woocommerce_rest_prepare_product_object", "prepare_product_images", 10, 3);
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Hello. Thank you for contacting the Toolset support.
Toolset offers the REST integration and here is the Doc for that:
=> https://toolset.com/documentation/programmer-reference/toolset-integration-with-the-rest-api/#how-the-integration-works
For the data return in REST, for the image fields it returns the attachent ID as you can see with the following table:
=> https://toolset.com/documentation/programmer-reference/toolset-integration-with-the-rest-api/#field-types-and-their-value-format-in-rest-api
I would like to know on what endpoint you would like to generate the image with your custom size 300x300 - correct? and you want to return the 300x300 image URL as a result of your endpoint- right?
My issue is resolved now. Thank you!