Announcement

Collapse
No announcement yet.

Shadows Imagemachine bug. -- Fails if image filename contains spaces.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Shadows Imagemachine bug. -- Fails if image filename contains spaces.

    FYI for anyone that encounters this.

    In the following Part of the Shadows ImageMachine Head Template:

    Code:
    let InitializePhotoViewer = function (clickedImage) {
    if (images.length === 1) {
    PhotoViewerControls.classList.add('u-invisible');
    }
    console.log(images.length);
    
    for (let i = 0; i < images.length; i++) {
    if (images[i].hasOwnProperty('imageSrc')) {
    if (clickedImage.includes(images[i].imageSrc)) {
    OpenPhotoViewer(images[i]);
    }
    }
    }
    };
    This fails
    Code:
    if (clickedImage.includes(images[i].imageSrc))
    because clickedImage contains spaces encoded as "%20" and images[i].imageSrc contains spaces.

    Fix:
    Code:
    if ( decodeURI( clickedImage ).includes( decodeURI( images[i].imageSrc ) ) ) {
    Ray Yates
    "If I have seen further, it is by standing on the shoulders of giants."
    --- Sir Isaac Newton

    #2
    Hi Ray,

    Thanks for posting this. The issue will be addressed in the next Shadows release.
    Matt Zimmermann
    Front-End Development Director / Miva, Inc.

    Comment


      #3
      Good to know. I have tried for YEARS to get clients to not leave spaces in any file name but I can't seem to get through to all of them...
      Leslie Kirk
      Miva Certified Developer
      Miva Merchant Specialist since 1997
      Previously of Webs Your Way
      (aka Leslie Nord leslienord)

      Email me: [email protected]
      www.lesliekirk.com

      Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

      Comment


        #4
        Originally posted by lesliekirk View Post
        Good to know. I have tried for YEARS to get clients to not leave spaces in any file name but I can't seem to get through to all of them...
        It's not that people don't know, they simply forget or overlooked when copying and pasting data to save time. Image Machine, Product Code should have space and special character validation. It is a constant problem in-house and it creates a lot of problems and no easy fixes, its laborious and time consuming.
        Last edited by William Davis; 01-18-22, 01:50 PM.
        Thank you, Bill Davis

        Comment


          #5
          Filenames and product codes are different animals. Product codes are entered into the db/table and can be validated immediately. Image filenames may also be entered, but AFAIK, wouldn't enter the table until after the file has already been uploaded. Validating the filename could have some logistic implications. But also, the filename may not be invalid to the OS. Bottom line, the filename problem really needs to fixed at the source.

          Scott
          What help do you need today!
          Interactive Design Solutions http://www.southbound.com
          MivaMerchant Business Partner | Certified MivaMerchant Web Developer
          My T-shirt Collection is mostly MivaCon T-shirts!!
          Competitive Rates, Popular Modules, and Integrations:
          Product Copy | AutoBaskets | Waitlist Integration| Wholesale Integration

          Comment

          Working...
          X