I am trying to get text centered below my additional product images giving information as to what color of clothing I'm using. I am using Image Handler 2 to insert images and Magic Zoom to swap my images. I found a module called additional image titles, however, it is written to go in additional_images.php of the original file using image handler. Magic Zoom uses different code for additional_images.php and when I put in the new code from the module it will not work.
I think it has to do with different variable names. I have worked on this for days and can't get it to work. The code I am trying to add is:
// additional image titles
$add_img_constant = 'ADDIMG_' . strtoupper(str_replace(array('/','\\','.','-'),'_',substr_replace($base_image,'',0,7)));// if any other characters beside /\.- could be used in filepath, add them to array
if (defined($add_img_constant)) {//add text above or below images
$link = (ADDIMG_TEXT_TOP)? '<h4 class="addImgTitle">' . constant($add_img_constant) . '</h4>' . $link: $link . '<h4 class="addImgTitle">' . constant($add_img_constant) . '</h4>';
}
// /additional image titles
You Set this up in the library
In /includes/languages/english/extra_definitions/additional_image_titles_defines.php, define constants as shown.
define ('ADDIMG_TEXT_TOP',true);//change to false to put text below images
define ('ADDIMG_RINGS_RING23_01_JPG','Additional View #1'); //example title for /images/rings/ring23_01.jpg
define ('ADDIMG_HOE_SIDE_JPG','Side View'); //example title for /images/hoe_side.jpg
My Magiczoom code before I try and modify is:
<?php
/**
* (C) CopyRight 2008 MagicToolBox - 'www.magictoolbox.com' - [email protected]
*/
/*
image/
.....
subdir/
......
imageName.extension - base
imageName**.extension - additional
large/imageName**_LRG.extension - large images
medium/imageName**_MED.extension - medium images
MagicToolbox use only large images. All thumbnails will be dinamicaly created
*/
if (!defined('IS_ADMIN_FLAG')) die('Illegal Access');
// if Magic Zoom enabled
if (ZEN_MAGICZOOM_STATUS == 'true') {
//load module
require_once(DIR_FS_CATALOG . DIR_WS_MODULES . 'magictoolbox/magictoolbox_addons.php');
$mod = & magictoolboxLoadModule('MagicZoom');
$images = array();
if(!isset($GLOBALS['magictoolbox']['images'])) {
// we can load additional images only if base image present
if (!empty($products_image)) {
$info = pathinfo($products_image);
if(intval(phpversion()) < 5 || !isset($info["filename"])) {
$info["filename"] = basename($info["basename"], ".".$info["extension"]);
}
if($info["dirname"] == '.') $info["dirname"] = '';
if(!empty($info["dirname"])) $info["dirname"] .= '/';
$images = glob(DIR_FS_CATALOG . DIR_WS_IMAGES . $info["dirname"] . $info["filename"] . '*.' . $info["extension"]);
// found only original image
//if (count($images) == 1) $images = array();
// sort images
if (count($images) > 0) {
sort($images);
$_images = array();
foreach($images as $img) {
if($img == DIR_FS_CATALOG . DIR_WS_IMAGES . $info["dirname"] . $info["filename"] . '.' . $info["extension"]) {
$main = true;
} else {
$main = false;
}
$img = str_replace(DIR_FS_CATALOG . DIR_WS_IMAGES, '', $img);
$info = pathinfo($img);
if(intval(phpversion()) < 5 || !isset($info["filename"])) {
$info["filename"] = basename($info["basename"], ".".$info["extension"]);
}
if($info["dirname"] == '.') $info["dirname"] = '';
if(!empty($info["dirname"])) $info["dirname"] .= '/';
$lrg = 'large/' . $info['dirname'] . $info['filename'] . IMAGE_SUFFIX_LARGE .'.'. $info['extension'];
if(!file_exists(DIR_FS_CATALOG . DIR_WS_IMAGES . $lrg)) $lrg = $img;
$_images[] = array(
'main' => $main,
'img' => DIR_WS_CATALOG . magictoolboxGetThumb($lrg, 'original', $mod->params),
'medium' => DIR_WS_CATALOG . magictoolboxGetThumb($lrg, 'thumb', $mod->params),
'thumb' => DIR_WS_CATALOG . magictoolboxGetThumb($lrg, 'selector', $mod->params)
);
}
$GLOBALS['magictoolbox']['images'] = $images = $_images;
}
}
} else {
$images = $GLOBALS['magictoolbox']['images'];
}
if($mod->type == 'standard') {
$list_box_contents = array();
$title = '';
$c = count($images);
if ($c > 1) {
$row = $col = 0;
if ($c < IMAGES_AUTO_ADDED || IMAGES_AUTO_ADDED == 0 ) {
$col_width = floor(100/$c);
} else {
$col_width = floor(100/IMAGES_AUTO_ADDED);
}
foreach($images as $image) {
$img = $image['img'];
$medium = $image['medium'];
$thumb = $image['thumb'];
$id = 'MainImage';
$link = $mod->subTemplate(compact("img","thumb","medium","id"));
// List Box array generation:
$list_box_contents[$row][$col] = array('params' => 'class="additionalImages centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
'text' => "\n " . $link);
$col ++;
if ($col > (IMAGES_AUTO_ADDED -1)) {
$col = 0;
$row ++;
}
}
}
$num_images = $c;
}
} else {
//if disabled Magic Zoom then default template will be loaded
require_once(dirname(dirname(__FILE__)) . "/" . basename(__FILE__));
}
?>
Can anyone please help, not sure what to do.
Bookmarks