add a product image by filename

shopp_add_product_image ( $product, $file )

@param int $product Product id to attach the image asset to.
@param string $file Full or correct relative path to the image file.
@return mixed false on failure, int image asset id on success.


Add a product image by filename.

Requires full path to the file on your filesystem, or a correct relative path from the WP_CONTENT_DIR. The file will be stored in the currently active storage engine.


$file = '/path/to/file.jpg';

// Lookup product named "My Product"
$Product = shopp_product( 'My Product', 'name');

// add image to product named "My Product"
$id = shopp_add_product_image( $Product->id, $file );

// set the product to the global product context
ShoppProduct( $Product );

// display new image using the named image setting 'showcase'
shopp( 'product', 'image', "id=$id&setting=showcase");

See Also

You must be logged in to post a comment.

© Ingenesis Limited. Shopp™ is a registered trademark of Ingenesis Limited.