Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-image slides cause "Uncaught TypeError" #556

Open
CrystalFyre opened this issue Sep 25, 2019 · 1 comment
Open

Non-image slides cause "Uncaught TypeError" #556

CrystalFyre opened this issue Sep 25, 2019 · 1 comment

Comments

@CrystalFyre
Copy link

CrystalFyre commented Sep 25, 2019

In version 4.6.3, you could mix content in a Fotorama slider. IMGs, then . This worked fine.

In version 4.6.4, any HTML slides (non images or anchor links), now trip up the script.
Uncaught TypeError: Cannot read property 'attr' of null

The function "getDimensions", close to line 1207 in "fotorama.min.js", now attempts to check for attributes for "alt" and "title" of a child element, but the function that calls this, sends a null as the object, so checking for attributes on a null element cause it to crash.

  function getDimensions ($img, $child, imgData) {
    var separateThumbFLAG = imgData.thumb && imgData.img !== imgData.thumb,
        width = numberFromMeasure(imgData.width || $img.attr('width')),
        height = numberFromMeasure(imgData.height || $img.attr('height')),
        alt    = $child.attr('alt'),
        title  = $child.attr('title');

        if (alt)   { $.extend(imgData, { alt: alt }); }
        if (title) { $.extend(imgData, { title: title }); }

    $.extend(imgData, {
      width: width,
      height: height,
      thumbratio: getRatio(imgData.thumbratio || (numberFromMeasure(imgData.thumbwidth || ($child && $child.attr('width')) || separateThumbFLAG || width) / numberFromMeasure(imgData.thumbheight || ($child && $child.attr('height')) || separateThumbFLAG || height)))
    });

The two lines, "alt = $child.atr('alt')" and 'title = $child.attr('title')" trigger this error. HTML slides are sent to "getDimensions" with a Null child.
There should be a check in place to make sure a child exists, before attempting to get their attributes.

(My apologies, this is my first time submitting an issue. I hope this is okay?)

@CrystalFyre
Copy link
Author

CrystalFyre commented Sep 26, 2019

Like this...

        alt    = ($child) ? $child.attr('alt') : null,
        title  = ($child) ? $child.attr('title') : null;

I've temporarily patched my script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant