Image gallery not displaying & removing random element

I tried to use parts of a I found, but when I use my images, it will not display. I am not the greatest at javascript, so I’m wondering if the error lies in that section. I believe there is a random element organizing the pictures, but I can’t tell where it is in the code. Also, sometimes my image do display and other times they will not. Please help!


Hello dan.

I am not sure why you would particularly even have this section:

gallery.querySelectorAll('img').forEach(function (item) {
    if (item.complete) {
    else {
        item.addEventListener('load', function () {
            var altura = getVal(gallery, 'grid-auto-rows');
            var gap = getVal(gallery, 'grid-row-gap');
            var gitem = item.parentElement.parentElement;
   = "span " + Math.ceil((getHeight(gitem) + gap) / (altura + gap));

I would remove this, if I were you.

Hope that helps.

1 Like

I wasn’t too sure about what the javascript did because I haven’t got too far into the lessons for it, but I wanted the function that allowed for the image to be clicked on and resized. I wasn’t too sure if I removed parts if it would ruin that feature as well, but thank you for the solution! this is what I needed