Forums / Templates, Stylesheets, Page Layout / Multiple Images for One Listing Questions

Multiple Images for One Listing Questions

Locked

Views: 9,727

Results 41 to 48 of 48
This thread is locked. New replies are disabled.
28 Oct 2007, 12:57 AM
#41
donn avatar

donn

Zen Follower

Join Date:
Oct 2007
Posts:
241
Plugin Contributions:
0

Multiple Images for One Listing Questions

gjh42:

The product base image (in /images/ or /images/your_subdir/) is the thumbnail: the smallest sized image.
You don't want additional images at thumbnail size, ever - that's what all the work is about, to get medium-sized additional images on the product info page.

OK, that's what i thought, as the file in /images/ is the lowest-res (product listing thumbnail-sized)

So the additional files w/o the suffix _MED and _LRG should be unnecessary if I am seeking medium-sized additional images....OK..makes sense... [/QUOTE]

gjh42:

The stock ZC code requires a thumbnail-sized image for every product image, main or additional. My mods change that to requiring a medium-sized image for the additional images, and a large image if desired.
$products_image_match_array = array();

OK, thanks....this seems right on target! : )

gjh42:

We have both spent a lot of time trying to describe what we think code may or may not do; it would save a lot of energy if you try the code and see what it does. If it doesn't work, I'll troubleshoot it. Save a copy of the original file.

OK...I've been doing that...before I started all this I saved the default additional images.php file. I have a few variations I've tried since, just playing around.

Ill give this a try and report back my results.

have a good weekend.

28 Oct 2007, 7:36 AM
#42
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Multiple Images for One Listing Questions

Here is the complete modified additional_images.php:```php

<?php /** * additional_images module * * Prepares list of additional product images to be displayed in template * * @package templateSystem * @copyright Copyright 2003-2006 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 * @version $Id: additional_images.php 5369 2006-12-23 10:55:52Z drbyte $ * Modified to use medium-sized additional images by gjh42 20071026 */ if (!defined('IS_ADMIN_FLAG')) { die('Illegal Access'); } if (!defined('IMAGE_ADDITIONAL_DISPLAY_LINK_EVEN_WHEN_NO_LARGE')) define('IMAGE_ADDITIONAL_DISPLAY_LINK_EVEN_WHEN_NO_LARGE','Yes'); $images_array = array(); if ($products_image != '') { // prepare image name $products_image_extension = substr($products_image, strrpos($products_image, '.')); $products_image_base = str_replace($products_image_extension, '', $products_image); // if in a subdirectory if (strrpos($products_image, '/')) { $products_image_match = substr($products_image, strrpos($products_image, '/')+1); //echo 'TEST 1: I match ' . $products_image_match . ' - ' . $file . ' - base ' . $products_image_base . '<br>'; $products_image_match = str_replace($products_image_extension, '', $products_image_match) . '_'; $products_image_base = $products_image_match; } $products_image_directory = str_replace($products_image, '', substr($products_image, strrpos($products_image, '/'))); if ($products_image_directory != '') { //med add: product is in a subdir - insert medium/ into dir path $products_image_directory = DIR_WS_IMAGES . str_replace($products_image_directory, '', $products_image) . "/"; $products_image_directory_medium = DIR_WS_IMAGES . 'medium/' . str_replace($products_image_directory, '', $products_image) . "/"; } else { //med add: product is in /images/ - insert medium/ into dir path $products_image_directory = DIR_WS_IMAGES; $products_image_directory_medium = DIR_WS_IMAGES . 'medium/'; } // Check for additional matching images $file_extension = $products_image_extension; $products_image_match_array = array(); if ($dir = @dir($products_image_directory_medium)) { //med add: if med is valid dir while ($file = $dir->read()) { if (!is_dir($products_image_directory_medium . $file)) { //med add: if item being read is file, not subdir if (substr($file, strrpos($file, '.')) == $file_extension) { // if(preg_match("/" . $products_image_match . "/i", $file) == '1') { if(preg_match("/" . $products_image_base . "/i", $file) == '1') { if ($file != (str_replace($products_image_extension, '', $products_image) . IMAGE_SUFFIX_MEDIUM . $products_image_extension)) { //med add: check against main med img, not main thumb if ($products_image_base . str_replace($products_image_base, '', $file) == $file) {//med add: filename must not have _MED suffix //if (substr($file, strrpos($file, IMAGE_SUFFIX_MEDIUM)) == IMAGE_SUFFIX_MEDIUM . $file_extension) { //med add: if filename ends in _MED // echo 'I AM A MATCH ' . $file . '<br>'; $images_array[] = $file; } else { // echo 'I AM NOT A MATCH ' . $file . '<br>'; } } } } } } if (sizeof($images_array)) { sort($images_array); } $dir->close(); } } // Build output based on images found $num_images = sizeof($images_array); $list_box_contents = ''; $title = ''; if ($num_images) { $row = 0; $col = 0; if ($num_images < IMAGES_AUTO_ADDED || IMAGES_AUTO_ADDED == 0 ) { $col_width = floor(100/$num_images); } else { $col_width = floor(100/IMAGES_AUTO_ADDED); } for ($i=0, $n=$num_images; $i<$n; $i++) { $file = $images_array[$i]; $products_image_large = str_replace(DIR_WS_IMAGES, DIR_WS_IMAGES . 'large/', $products_image_directory) . str_replace($products_image_extension, '', $file) . IMAGE_SUFFIX_LARGE . $products_image_extension; $flag_has_large = file_exists($products_image_large); $products_image_large = ($flag_has_large ? $products_image_large : $products_image_directory . $file); $flag_display_large = (IMAGE_ADDITIONAL_DISPLAY_LINK_EVEN_WHEN_NO_LARGE == 'Yes' || $flag_has_large); $base_image = $products_image_directory_medium . $file; //med add: use med dir $thumb_slashes = zen_image($base_image, addslashes($products_name), MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT); //med add: medium w & h $thumb_regular = zen_image($base_image, $products_name, MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT); //med add: medium w & h $large_link = zen_href_link(FILENAME_POPUP_IMAGE_ADDITIONAL, 'pID=' . $_GET['products_id'] . '&pic=' . $i . '&products_image_large_additional=' . $products_image_large); // Link Preparation: $script_link = '<script language="javascript" type="text/javascript"><!--' . "\n" . 'document.write(\'' . ($flag_display_large ? '<a href="javascript:popupWindow(\\\'' . $large_link . '\\\')">' . $thumb_slashes . '<br />' . TEXT_CLICK_TO_ENLARGE . '</a>' : $thumb_slashes) . '\');' . "\n" . '//--></script>'; $noscript_link = '<noscript>' . ($flag_display_large ? '<a href="' . zen_href_link(FILENAME_POPUP_IMAGE_ADDITIONAL, 'pID=' . $_GET['products_id'] . '&pic=' . $i . '&products_image_large_additional=' . $products_image_large) . '" target="_blank">' . $thumb_regular . '<br /><span class="imgLinkAdditional">' . TEXT_CLICK_TO_ENLARGE . '</span></a>' : $thumb_regular ) . '</noscript>'; // $alternate_link = '<a href="' . $products_image_large . '" onclick="javascript:popupWindow(\''. $large_link . '\') return false;" title="' . $products_name . '" target="_blank">' . $thumb_regular . '<br />' . TEXT_CLICK_TO_ENLARGE . '</a>'; $link = $script_link . "\n " . $noscript_link; // $link = $alternate_link; // 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 ++; } } // end for loop } // endif ?>
30 Oct 2007, 12:14 AM
#43
donn avatar

donn

Zen Follower

Join Date:
Oct 2007
Posts:
241
Plugin Contributions:
0

Re: Multiple Images for One Listing Questions

gjh42:

Here is the complete modified additional_images.php:[php]

<?php /** * additional_images module * * Prepares list of additional product images to be displayed in template * * @package templateSystem * @copyright Copyright 2003-2006 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 * @version $Id: additional_images.php 5369 2006-12-23 10:55:52Z drbyte $ * Modified to use medium-sized additional images by gjh42 20071026 */

OK.......I installed this additional_images.php file.

The correct additional images seem to appear in _MED size.

So far, everything seems to work OK. I will play around with this a bit and tell you what happens.

BTW, you all have been really helpful!

THANK YOU KINDLY!!!!!!!!!!!!!!!
:smile:

30 Oct 2007, 2:21 AM
#44
donn avatar

donn

Zen Follower

Join Date:
Oct 2007
Posts:
241
Plugin Contributions:
0

Re: Multiple Images for One Listing Questions

Ok...I tested this with the images in the /images/ dir. All additonal images displayed, correct _MED files, in medium size.

When I put set the product to find the images in the /images/subdir/ with all the same associated files...

Additional images NO LONGER display!!!

I plan to use subfolders, so this will be an issue.


ALSO...

When I set the product image back to /images/image.jpg and associated files (as I had it in my first test), there is no 'click for larger' link even if larger images ARE present (in the /large/ dir, without using any subdir).

I had made a modification that checks whether a large image is there or not, and then displays,or doesn't display the link. The mod was provided in thread Additional_Images.php Line 16-display link if no large

Thanks!

30 Oct 2007, 5:27 AM
#45
donn avatar

donn

Zen Follower

Join Date:
Oct 2007
Posts:
241
Plugin Contributions:
0

Re: Multiple Images for One Listing Questions

Donn:

Ok...I tested this with the images in the /images/ dir. All additonal images displayed, correct _MED files, in medium size.

When I put set the product to find the images in the /images/subdir/ with all the same associated files...

Additional images NO LONGER display!!!

Note: I didn't explain that I did, in fact, have the _MED and _LRG files in the associated
medium/subdir and large/subdir. I realize I was unclear and that missing files and/or subdirs , of course, could create the same issue of no additional photos.

Just trying to be clear........!

30 Oct 2007, 8:04 AM
#46
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Multiple Images for One Listing Questions

I'll take a closer look at this when I get time tomorrow night. I can install it in my local test ZC to see what happens with this mod and nothing else.

"I had made a modification that checks whether a large image is there or not, and then displays,or doesn't display the link. The mod was provided in thread Additional_Images.php Line 16-display link if no large"

I think this would never find the medium and/or large additional image files correctly, so would always disable the larger image link...

8 Nov 2007, 10:52 PM
#47
donn avatar

donn

Zen Follower

Join Date:
Oct 2007
Posts:
241
Plugin Contributions:
0

Re: Multiple Images for One Listing Questions

gjh42:

I'll take a closer look at this when I get time tomorrow night. I can install it in my local test ZC to see what happens with this mod and nothing else.

"I had made a modification that checks whether a large image is there or not, and then displays,or doesn't display the link. The mod was provided in thread Additional_Images.php Line 16-display link if no large"

I think this would never find the medium and/or large additional image files correctly, so would always disable the larger image link...

The script change I quoted in post 'Additional_Images.php Line 16' does, in fact, work at finding the large photos if they are there, and keeps the link from displaying if not present.

Did you happen to have a chance to look at the problem of medium additional images again? For now, I've just set everything to default.

Thanks...

9 Nov 2007, 6:41 AM
#48
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Multiple Images for One Listing Questions

I wish the forum had a way to mark posts as unread, so it would be easier to remember threads you wanted to get back to...
I'm heading out of town, but will check on it when I return (note written to myself:).