Advanced Features 

Examples for implementing lightbox functionality and lazy loading for performance optimization.

Lazy Loading 

Native Lazy Loading 

Objective: Improve page load performance with native lazy loading

TypoScript Setup 

lib.parseFunc_RTE {
    nonTypoTagStdWrap.HTMLparser.tags.img {
        fixAttrib {
            loading {
                set = lazy
            }
            # Remove internal attributes
            data-htmlarea-file-uid.unset = 1
            data-htmlarea-file-table.unset = 1
            data-htmlarea-zoom.unset = 1
        }
    }
}
Copied!

Result HTML 

<img src="..." loading="lazy" alt="..." />
Copied!

Intersection Observer Fallback 

For older browsers:

TypoScript 

page.includeJSFooterlibs.lazyload = EXT:my_site/Resources/Public/JavaScript/lazyload.js

lib.parseFunc_RTE {
    nonTypoTagStdWrap.HTMLparser.tags.img {
        fixAttrib {
            class {
                list = lazyload
            }
            data-src {
                # Copy src to data-src
                stdWrap.field = src
            }
            src {
                # Set placeholder
                set = data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 3 2'%3E%3C/svg%3E
            }
        }
    }
}
Copied!

JavaScript 

EXT:my_site/Resources/Public/JavaScript/lazyload.js
document.addEventListener('DOMContentLoaded', function() {
    const imageObserver = new IntersectionObserver((entries, observer) => {
        entries.forEach(entry => {
            if (entry.isIntersecting) {
                const img = entry.target;
                img.src = img.dataset.src;
                img.classList.remove('lazyload');
                imageObserver.unobserve(img);
            }
        });
    });

    document.querySelectorAll('img.lazyload').forEach(img => {
        imageObserver.observe(img);
    });
});
Copied!

Result: Progressive image loading ✅