[🪲BUG] Image Lazy Loading Breaks Components Using `data-src` Attributes And Produces Double-slash URLs - Question | JoomShaper

[🪲BUG] Image Lazy Loading Breaks Components Using `data-src` Attributes And Produces Double-slash URLs

Brad Thompson

Brad Thompson

EasyStore 2 weeks ago

Extension: Helix Ultimate (system plugin) Version: (latest, Joomla 6)

Description:

The onAfterRender() image lazy loading feature in plugins/system/helixultimate/helixultimate.php has two bugs that break image loading for any component that already uses data-src attributes for its own lazy loading (e.g., EasyStore product thumbnails).

Bug 1: Regex matches data-src inside src pattern

At line ~874:

$imageElement = preg_replace("@src(?=\=[\"\']([^\"\']*)[\"\'])@", "data-src", $imageElement);

The regex src(?=\=...) matches src= inside data-src=, renaming data-src → data-data-src and src → data-src. The component's actual image URL ends up in data-data-src (which no lazy loader reads), and data-src points to the placeholder. Images never load.

Suggested fix: Use a negative lookbehind to exclude data- prefixed attributes:

$imageElement = preg_replace("@(?<!data-)src(?=\=[\"\']([^\"\']*)[\"\'])@", "data-src", $imageElement);

Bug 2: Double slash in generated URLs

At line ~847-849:

if (preg_match("@(^images\/|^\/+images\/).*$@", $match))
{
    $update = Uri::base() . $_match;

Uri::base() returns a URL with a trailing slash (e.g., example.com/). When $_match starts with /images/..., the concatenation produces example.com//images/... — a double slash.

Suggested fix: Strip the leading slash before concatenating:

$update = rtrim(Uri::base(), '/') . '/' . ltrim($_match, '/');

Steps to reproduce:

  1. Enable image_lazy_loading in Helix Ultimate template settings.
  2. Install EasyStore and add products with images.
  3. View a product listing page (e.g., /accessories).
  4. Inspect the image elements — data-src will point to the placeholder, data-data-src will contain the actual image URL with a double slash, and images will not load.

Expected behavior: Helix's lazy loading should only process <img> tags that use src= (not data-src=), and should not produce URLs with double slashes.

Actual behavior: data-src attributes are renamed to data-data-src, src is renamed to data-src, and URLs contain double slashes. Images fail to load.

0
1 Answers
Mehtaz Afsana Borsha
Mehtaz Afsana Borsha
Accepted Answer
Support Agent 1 week ago #231963

Hello,

Thank you for reaching out to us and for taking the time to share this solution. I have forwarded your details and proposed fix to our development team for review.

Best regards.

0