...
- General shop images
- Product images
- Category images
- Customization images
- Manufacturer images
- Supplier images
- Store images
...
- /api/images/general
- /api/images/products
- /api/images/categories
- /api/images/customizations
- /api/images/manufacturers
- /api/images/suppliers
- /api/images/stores
Various image size are available, depending on the image types. They are available as XLink links in the links above, encapsulated in the image_types
node.
...
For instance, here is how to change the image for category 2:
- HTTP method: POST ( /!\ not PUT)
- URL: /images/categories/2
- ParametersPOST content: images= [binary content for the new image]
...and here is how to add a new image to the product with id '1':
- HTTP method: POST
- URL: /images/products/1
- ParametersPOST content: images= [binary content for the new image]
Here is an HTML form enabling images to be sent:
Code Block | ||
---|---|---|
| ||
<form enctype="multipart/form-data" method="POST" action="http://[email protected]/api/images/products/1"> <fieldset> <legend>Add image for products No 1</legend> <input type="file" name="image"> <input type="submit" value="Execute"> </fieldset> </form> |
Code Block | ||
---|---|---|
| ||
<form action="http://[email protected]/api/images/customizations/6/1/8" method="POST" enctype="multipart/form-data">
<fieldset>
<legend>Update image change 1/8</legend>
<input name="ps_method" value="PUT" type="hidden">
<input name="image" type="file">
<input value="Execute" type="submit">
</fieldset>
</form> |
If you would rather use cURL:
Code Block |
---|
$url = 'http://myprestashop.com/api/images/products/1'; /** * Uncomment the following line in order to update an existing image */ //$url = 'http://myprestashop.com/api/images/products/1?ps_method=PUT'; $image_path = 'C:\\my_image.png'; $key = 'My web service key'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_PUT, true); // Un-commet to edit an image curl_setopt($ch, CURLOPT_USERPWD, $key.':'); curl_setopt($ch, CURLOPT_POSTFIELDS, array('image' => '@'.$image_path)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); curl_close($ch); |