Page 4 of 5 FirstFirst ... 2345 LastLast
Results 31 to 40 of 48
  1. #31
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Multiple Images for One Listing Questions

    Before studying the rest of the file again, I observe that $products_image_base is the key to this. What is the value of that? If it is the additional image name (without _MED suffix), the correct medium additional image should be called. If it is the main product base (thumbnail) image name, it would give the results observed.

    "MEDIUM additional files are displayed, but they are just the base image, and not the base image_01, _02, etc."

    What is the full filename of the image being displayed? Is it the main thumbnail file or the main medium file?

  2. #32
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Multiple Images for One Listing Questions

    Assuming you only want to use medium additional images, this will build the additional image list from the medium folder. You will not need additional image files in the thumbnail folder; the image names will need the _MED suffix.
    The code is spread out more than DrByte's example. Find
    PHP Code:
      $products_image_directory str_replace($products_image''substr($products_imagestrrpos($products_image'/')));
      if (
    $products_image_directory != '') {
        
    $products_image_directory DIR_WS_IMAGES str_replace($products_image_directory''$products_image) . "/";
      } else {
        
    $products_image_directory DIR_WS_IMAGES;
      }

      
    // Check for additional matching images
      
    $file_extension $products_image_extension;
      
    $products_image_match_array = array();
      if (
    $dir = @dir($products_image_directory)) {
        while (
    $file $dir->read()) {
          if (!
    is_dir($products_image_directory $file)) {
            if (
    substr($filestrrpos($file'.')) == $file_extension) {
              
    //          if(preg_match("/" . $products_image_match . "/i", $file) == '1') {
              
    if(preg_match("/" $products_image_base "/i"$file) == '1') {
                if (
    $file != $products_image) {
                  if (
    $products_image_base str_replace($products_image_base''$file) == $file) {
                    
    //  echo 'I AM A MATCH ' . $file . '<br>';
                    
    $images_array[] = $file;
                  } else {
                    
    //  echo 'I AM NOT A MATCH ' . $file . '<br>';
                  

    and replace with
    PHP Code:
      $products_image_directory str_replace($products_image''substr($products_imagestrrpos($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($filestrrpos($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) {
                    if (
    substr($filestrrpos($fileIMAGE_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>';
                    
    //med add: substr
                  

    Find
    PHP Code:
        $base_image $products_image_directory $file;
        
    $thumb_slashes zen_image($base_imageaddslashes($products_name), SMALL_IMAGE_WIDTHSMALL_IMAGE_HEIGHT);
        
    $thumb_regular zen_image($base_image$products_nameSMALL_IMAGE_WIDTHSMALL_IMAGE_HEIGHT); 
    and replace with
    PHP Code:
        $base_image $products_image_directory_medium $file//med add: use med dir
        
    $thumb_slashes zen_image($base_imageaddslashes($products_name), MEDIUM_IMAGE_WIDTHMEDIUM_IMAGE_HEIGHT); //med add: medium w & h
        
    $thumb_regular zen_image($base_image$products_nameMEDIUM_IMAGE_WIDTHMEDIUM_IMAGE_HEIGHT); //med add: medium w & h 
    Note: this is not yet tested. Please let me know how it works.

  3. #33
    Join Date
    Oct 2007
    Posts
    241
    Plugin Contributions
    0

    Default Re: Multiple Images for One Listing Questions

    Thanks for the code. I still haven't tried it.

    Would your revision cause the thumbnails (displayed in categotry listings) to actually be the _MED file, just displayed smaller? I know that can slow down a page's load time.


    PS where is the thumbnail folder you refer to?

    As I understood it...the listing photo (thumbnail?) is in /images/

    is there another thumbnail directory? Is the thumbnail something else, other than the image used for the category items listings?

  4. #34
    Join Date
    Oct 2007
    Posts
    241
    Plugin Contributions
    0

    Default Re: Multiple Images for One Listing Questions

    Quote Originally Posted by gjh42 View Post
    Before studying the rest of the file again, I observe that $products_image_base is the key to this. What is the value of that? If it is the additional image name (without _MED suffix), the correct medium additional image should be called. If it is the main product base (thumbnail) image name, it would give the results observed.

    "MEDIUM additional files are displayed, but they are just the base image, and not the base image_01, _02, etc."

    What is the full filename of the image being displayed? Is it the main thumbnail file or the main medium file?
    It depends, actually.

    If I upload the files to the /images/ root directory, as well as medium images to /images/medium, and larges to /images/large/, and point the product image dropdown to Main Directory.....

    Additional files WILL display MEDIUM sized, BUT all of them will be the same EXACT file:


    'image_MED.jpg'.


    There will be exactly as many duplicate additional images displayed as there are files in the /images/ dir that have the same product name (and also containing additional characters after the name)

    NOTE: As an additional test, Iadded some _MED files into the /images/ folder. Zencart counted these as well as the product_01, _02 files. In toher words, if I had 2 additional images in the /images/ dir, it would display 2 additional image_MED files. If I also add 2 more _MED files to the /images/ dir, it will display FOUR of the same duplicate _MED image

    so...does that mean that ZC will treat ANY files in the /images/ folder (/images/subfolder/) as additionals, as long as the files contain ANY extra characters beyond the base name?



    BUT....if I select a subfolder....(which is the way I plan to organize my products)
    And do everything else the same, except upload the files to the subfolder in
    images/subfolder

    images/large/subfolder


    and

    images/medium/subfolder

    what displays is exactly what would if I didn't have Dr. Zen's change in the script: I get the correct additionals, displayed in product listing size, NOT medium, even though the medium images are right there in the corresponding images/subfolder. If I ALSO put the _MED files in the /images/medium/ folder (Still having the product set to the sub-dir) i STILL get the same results: The correct additionals, obviously from the subfolder, only small sized.

    Again, all large clickables are perfect, both with the above and below tests.
    Last edited by Donn; 26 Oct 2007 at 12:09 AM.

  5. #35
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Multiple Images for One Listing Questions

    This code would not affect anything that would show on the listing page. The additional images are displayed only on the product info page.

  6. #36
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Multiple Images for One Listing Questions

    "Additional files WILL display MEDIUM sized, BUT all of them will be the same EXACT file:


    'image_MED.jpg'."

    This is what I thought DrByte's code as posted would do.

    The "subfolder" results I'm not sure about - wloud have to reanalyze the code to see what I think it should do.
    At any rate, the code I posted will eliminate the need to put unused copies of additional images in the main /images/subfolder.

  7. #37
    Join Date
    Oct 2007
    Posts
    241
    Plugin Contributions
    0

    Default Re: Multiple Images for One Listing Questions

    Quote Originally Posted by gjh42 View Post
    "Additional files WILL display MEDIUM sized, BUT all of them will be the same EXACT file:


    'image_MED.jpg'."

    This is what I thought DrByte's code as posted would do.
    The additional images are ALL just 'image_MED.jpg''
    when they SHOULD be 'image_01_MED.jpg', 'image_02_MED.jpg', etc.

    So I end up seeing the main product descrition photo repeated again and again in medium size, corresponding to the number of base images ZC finds. (If, and only if, I use /images as the DIR...again, subdirs do not work---using subdirs w/ Dr Zen's changes results in NO change at all...works exactly as it did before the alteration...displaying the CORRECT additional photos, but in SMALL size, even when _MED files are there and in the correct dir / subdir)



    Quote Originally Posted by gjh42 View Post
    The "subfolder" results I'm not sure about - wloud have to reanalyze the code to see what I think it should do.

    At any rate, the code I posted will eliminate the need to put unused copies of additional images in the main /images/subfolder.
    Arent the images in the main/images(/subfoolder) supposed to be at lowest resolution., though?
    If I use exclusively _MEd and _LRG files, wont ZC ahve to calculate the lo-res category listing photos from the _MEDs. Wont this slow the cart down?

    Im confused as to how they'd be unused....
    Last edited by Donn; 26 Oct 2007 at 02:23 AM.

  8. #38
    Join Date
    Oct 2007
    Posts
    241
    Plugin Contributions
    0

    Default Re: Multiple Images for One Listing Questions

    Quote Originally Posted by gjh42 View Post
    This code would not affect anything that would show on the listing page. The additional images are displayed only on the product info page.
    I keep getting the terminology mixed up...sorry about that...

    What you wrote is what I MEANT to say....
    PROD DESCRPTION page, and not the cat listings....

    duh

  9. #39
    Join Date
    Oct 2007
    Posts
    241
    Plugin Contributions
    0

    Default Re: Multiple Images for One Listing Questions

    Quote Originally Posted by Donn View Post
    If I use exclusively _MEd and _LRG files, wont ZC ahve to calculate the lo-res category listing photos from the _MEDs. Wont this slow the cart down?.
    Or does the ZC just display the _MED files, smaller, but at the same effective resolution?

    Both methods of dealing with a missing image file (no MEd or LRG suffix) would slow down the ZC software.

    But Im still not sure what your code does....exactly....

    Whaty do you mean about thumbnails? Are the image files (no suffix MED or LRG) the thumbnails you refer to?

  10. #40
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Multiple Images for One Listing Questions

    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.

    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.

    ----------------------------------------------------------------------
    Note: I have just noticed a bug in my code - the large images would need to be named filename_MED_LRG.jpg to work as written. It would be possible to strip the _MED from the base that generates the large filename, but it would be much simpler to eliminate a line of my code and not require the additional images in the /medium/ folder to have _MED in their names.
    So... replace the first new code block in post 32 with
    PHP Code:
      $products_image_directory str_replace($products_image''substr($products_imagestrrpos($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($filestrrpos($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 end in _MED, to ease large file use
                    //  echo 'I AM A MATCH ' . $file . '<br>';
                    
    $images_array[] = $file;
                  } else {
                    
    //  echo 'I AM NOT A MATCH ' . $file . '<br>';
                  

    Name your additional images like
    filename_01.jpg, and save in
    /images/medium/your_subdir/ .

    ----------------------------------------------------------------------
    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 (it should still be there at /includes/modules/additional_images.php) so if something goes wrong with /includes/modules/your_template/additional_images.php you can easily recover. This is standard procedure.

 

 
Page 4 of 5 FirstFirst ... 2345 LastLast

Similar Threads

  1. How can I add multiple images for ONE product through the Admin page?
    By stevewag in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 20 Apr 2009, 09:57 AM
  2. Multiple images for one item ? ? ?
    By ve39 in forum General Questions
    Replies: 7
    Last Post: 22 Oct 2008, 06:56 AM
  3. Questions about emailing multiple customers at one time
    By BouncerFL in forum General Questions
    Replies: 0
    Last Post: 1 Apr 2008, 05:57 PM
  4. Multiple Images Questions
    By manifest in forum Templates, Stylesheets, Page Layout
    Replies: 12
    Last Post: 3 Mar 2008, 10:44 PM
  5. Stock control - listing multiple items as one
    By chmac in forum General Questions
    Replies: 3
    Last Post: 10 Sep 2007, 01:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg