Extending CW4 to use multiple images (admin)
This is a quick explanation of setting up multiple images in your Cartweaver 4 store admin, in both PHP and CFML.
As of this post, the Cartweaver 4 product details admin contains a single image upload area. The user can browse for a photo on the local computer, upload the image, and the image will be resized into the 4 standard formats (thumbnail, zoom etc).
However, extending this functionality to include multiple image upload areas is simply a matter of adding some records to the table “cw_image_types”. Simply put, you want to copy the existing 5 rows, and change the ‘upload group’ number. That’s it.
To explain, here is the mySQL dump of the cw_image_types table containing 6 separate image upload areas - SEE BELOW - and a screenshot from our favorite db admin program, Navicat, showing the data in spreadsheet format.
Note the all-important “imagetype_upload_group” column, which specifies not only how many image uploader areas there are in the admin, but which sizes are created.
And here is a screenshot of the admin area, with 6 image upload slots, ready to go.
This SQL script can be pasted into your own db-sql.sql file before setup, in place of the current cw_image_types section, or simply execute the queries from group 2 through 6 (below) in your own mySQL admin program.
Also, Navicat and other db admin tools will let you copy and paste records just like rows of a spreadsheet.
However you approach it, the concept is the same, duplicate the existing default entries in cw_image_types, and change the “upload group” to create the various uploader areas on the images tab.
/*DROP TABLE IF EXISTS `cw_image_types`;
CREATE TABLE `cw_image_types` ( `imagetype_id` int(11) NOT NULL AUTO_INCREMENT, `imagetype_name` varchar(100) DEFAULT NULL, `imagetype_sortorder` float(11,3) DEFAULT '1.000', `imagetype_folder` varchar(50) DEFAULT NULL, `imagetype_max_width` int(10) DEFAULT NULL, `imagetype_max_height` int(10) DEFAULT NULL, `imagetype_crop_width` int(10) DEFAULT NULL, `imagetype_crop_height` int(10) DEFAULT NULL, `imagetype_upload_group` int(2) DEFAULT '1', `imagetype_user_edit` tinyint(1) DEFAULT '1', PRIMARY KEY (`imagetype_id`) ) ENGINE=MyISAM AUTO_INCREMENT=31 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of cw_image_types
-- ----------------------------
INSERT INTO `cw_image_types` VALUES ('1', 'Thumbnail', '1.000', 'product_thumb', '160', '160', '0', '0', '1', '1');
INSERT INTO `cw_image_types` VALUES ('2', 'Details', '2.000', 'product_full', '420', '420', '0', '0', '1', '1');
INSERT INTO `cw_image_types` VALUES ('3', 'Zoom', '3.000', 'product_expanded', '680', '680', '0', '0', '1', '1');
INSERT INTO `cw_image_types` VALUES ('4', 'Cart', '4.000', 'product_small', '80', '80', '0', '0', '1', '1');
INSERT INTO `cw_image_types` VALUES ('5', 'SquareThumb', '5.000', 'product_thumb_square', '160', '160', '50', '50', '1', '0');
INSERT INTO `cw_image_types` VALUES ('6', 'Thumbnail', '1.000', 'product_thumb', '160', '160', '0', '0', '2', '1');
INSERT INTO `cw_image_types` VALUES ('7', 'Details', '2.000', 'product_full', '420', '420', '0', '0', '2', '1');
INSERT INTO `cw_image_types` VALUES ('8', 'Zoom', '3.000', 'product_expanded', '680', '680', '0', '0', '2', '1');
INSERT INTO `cw_image_types` VALUES ('9', 'Cart', '4.000', 'product_small', '80', '80', '0', '0', '2', '1');
INSERT INTO `cw_image_types` VALUES ('10', 'SquareThumb', '5.000', 'product_thumb_square', '160', '160', '50', '50', '2', '0');
INSERT INTO `cw_image_types` VALUES ('11', 'Thumbnail', '1.000', 'product_thumb', '160', '160', '0', '0', '3', '1');
INSERT INTO `cw_image_types` VALUES ('12', 'Details', '2.000', 'product_full', '420', '420', '0', '0', '3', '1');
INSERT INTO `cw_image_types` VALUES ('13', 'Zoom', '3.000', 'product_expanded', '680', '680', '0', '0', '3', '1');
INSERT INTO `cw_image_types` VALUES ('14', 'Cart', '4.000', 'product_small', '80', '80', '0', '0', '3', '1');
INSERT INTO `cw_image_types` VALUES ('15', 'SquareThumb', '5.000', 'product_thumb_square', '160', '160', '50', '50', '3', '0');
INSERT INTO `cw_image_types` VALUES ('16', 'Thumbnail', '1.000', 'product_thumb', '160', '160', '0', '0', '4', '1');
INSERT INTO `cw_image_types` VALUES ('17', 'Details', '2.000', 'product_full', '420', '420', '0', '0', '4', '1');
INSERT INTO `cw_image_types` VALUES ('18', 'Zoom', '3.000', 'product_expanded', '680', '680', '0', '0', '4', '1');
INSERT INTO `cw_image_types` VALUES ('19', 'Cart', '4.000', 'product_small', '80', '80', '0', '0', '4', '1');
INSERT INTO `cw_image_types` VALUES ('20', 'SquareThumb', '5.000', 'product_thumb_square', '160', '160', '50', '50', '4', '0');
INSERT INTO `cw_image_types` VALUES ('21', 'Thumbnail', '1.000', 'product_thumb', '160', '160', '0', '0', '5', '1');
INSERT INTO `cw_image_types` VALUES ('22', 'Details', '2.000', 'product_full', '420', '420', '0', '0', '5', '1');
INSERT INTO `cw_image_types` VALUES ('23', 'Zoom', '3.000', 'product_expanded', '680', '680', '0', '0', '5', '1');
INSERT INTO `cw_image_types` VALUES ('24', 'Cart', '4.000', 'product_small', '80', '80', '0', '0', '5', '1');
INSERT INTO `cw_image_types` VALUES ('25', 'SquareThumb', '5.000', 'product_thumb_square', '160', '160', '50', '50', '5', '0');
INSERT INTO `cw_image_types` VALUES ('26', 'Thumbnail', '1.000', 'product_thumb', '160', '160', '0', '0', '6', '1');
INSERT INTO `cw_image_types` VALUES ('27', 'Details', '2.000', 'product_full', '420', '420', '0', '0', '6', '1');
INSERT INTO `cw_image_types` VALUES ('28', 'Zoom', '3.000', 'product_expanded', '680', '680', '0', '0', '6', '1');
INSERT INTO `cw_image_types` VALUES ('29', 'Cart', '4.000', 'product_small', '80', '80', '0', '0', '6', '1');
INSERT INTO `cw_image_types` VALUES ('30', 'SquareThumb', '5.000', 'product_thumb_square', '160', '160', '50', '50', '6', '0');
As for how to use these images on the front end, in your site’s display, the key to getting any image is to duplicate the existing image display code, and change the number for the ‘image type’, which will match the value of the ‘imagetype_id’ in the the cw_image_types table (first column in the table view screenshot).
We look forward to seeing what you create with your Cartweaver store!


Recent Comments