Page 3 of 3 FirstFirst 123
Results 21 to 27 of 27
  1. #21
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Adding text to additional images individually

    The $file variable holds the filename only; $base_image has the subfolder (if any) plus filename.This code will handle any file (as long as it doesn't have spaces), and put the text above or below the image (depending on the value of a constant ADDIMG_TEXT_TOP which should be set in the definitions file):
    PHP Code:
        // additional image titles
        
    $badchars = array('/','\\','.','-',' ');//not allowed in constant names
        // if any other characters could be used in filepath, add them to $badchars
        
    $add_const_name 'ADDIMG_' strtoupper(str_replace($badchars,'_',$base_image));
        if (
    defined($add_const_name)) {//add text above or below images
          
    $link = (ADDIMG_TEXT_TOP)? '<div class="addImgTitle">' constant($add_const_name) . '</div>' $link$link '<div class="addImgTitle">' constant($add_const_name) . '</div>';
        }
        
    // /additional image titles
        // List Box array generation: 
    Add to the definition file:
    PHP Code:
    define ('ADDIMG_TEXT_TOP','true'};//change to false to put text below images 
    The $badchars setup is intended to convert spaces, but apparently is unable to do so. It will handle / \ . - characters.

  2. #22

    Default Re: Adding text to additional images individually

    Quote Originally Posted by gjh42 View Post
    Just because Microsoft lets users make file/folder names with spaces doesn't mean it's a good idea...
    It is a universal computer best practice to use only letters, numbers, _, -, . and perhaps one or two other characters in filenames. Keeping letters lower case is also a good idea, as some applications are case sensitive and forgetting what you capitalized can cause unexpected problems.
    Thank you for your suggestions and info on naming images and filenames. Much appreciated! I normally try not to use spaces. From now on I will be sure to follow that rule more rigorously. Thanks!

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

    Default Re: Adding text to additional images individually

    A bit more study revealed that $base_image has "images/" plus the subfolder (if any) plus filename. This requires a bit more processing, as shown:
    PHP Code:
        $add_const_name 'ADDIMG_' strtoupper(str_replace($badchars,'_',ereg_replace('(^images/)','',$base_image)));

        
    $add_const_name 'ADDIMG' strtoupper(ereg_replace('(^images/)[/\\.-]','_',$base_image)));//test if this works 
        
    echo $base_image $add_const_name
    The first version just adds another function to strip "images/" from the front of the string; the second version rolls up all of the replacement into one function.

    Please try the second version so I can get more verification that it works.

    PS -
    I really like your site (I'm a potter too.) I wish you would put the "powered by Zen Cart" link back into the footer so you can add it to the showcase as an example of what can really be done with the platform.
    Last edited by gjh42; 12 Jan 2009 at 06:24 AM.

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

    Default Re: Adding text to additional images individually

    After local testing, here is the final version of the additional image titles code:
    PHP Code:
        // additional image titles
        
    $add_img_const 'ADDIMG_' strtoupper(ereg_replace('[/\\.-]','_',substr_replace($base_image,'',0,7)));// if any other characters could be used in filepath, add them to list [  ]
        
    if (defined($add_img_const)) {//add text above or below images
          
    $link = (ADDIMG_TEXT_TOP)? '<h4 class="addImgTitle">' constant($add_img_const) . '</h4>' $link$link '<h4 class="addImgTitle">' constant($add_img_const) . '</h4>';
        }
        
    // /additional image titles 
    I would still appreciate a field tester before submitting the mod.

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

    Default Re: Adding text to additional images individually

    Additional Image Titles is now available in Free Addons.

    See the support thread for questions and further help.

  6. #26
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,973
    Plugin Contributions
    96

    Default Re: Adding text to additional images individually

    Wow! This installed like a dream. Thank you for the contribution!

  7. #27
    Join Date
    Sep 2008
    Posts
    53
    Plugin Contributions
    0

    Default Re: Adding text to additional images individually

    Quote Originally Posted by gjh42 View Post
    Just because Microsoft lets users make file/folder names with spaces doesn't mean it's a good idea...
    It is a universal computer best practice to use only letters, numbers, _, -, . and perhaps one or two other characters in filenames. Keeping letters lower case is also a good idea, as some applications are case sensitive and forgetting what you capitalized can cause unexpected problems.
    They should teach this in public schools. Along with "why you can't make digital pictures bigger".

 

 
Page 3 of 3 FirstFirst 123

Similar Threads

  1. Replies: 2
    Last Post: 3 Sep 2013, 10:19 PM
  2. v151 Is it possible to add images/text next to additional images?
    By pexter in forum General Questions
    Replies: 6
    Last Post: 21 May 2013, 09:47 PM
  3. Can I set a zoom name for additional images individually on product page?
    By wasabiman in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 14 Apr 2010, 12:46 PM
  4. Images On and off individually
    By ollie_dda in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 11 May 2008, 06:37 AM

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