Hi,
that is an 'old' setting that is not removed because I do not want to break things for people who are using it.
Basically there are two ways of searching for an element in HTML: via the DOM or via a regex.
- DOM: The Document Object Model (DOM) is a programming API for HTML and XML documents. It defines the logical structure of documents and the way a document is accessed and manipulated.
- Regex: Regular Expressions, commonly known as "regex" or "RegExp", are a specially formatted text strings used to find patterns in text. Regular expressions are one of the most powerful tools available today for effective and efficient text processing and manipulations.
So basically we have a HTML page (Generated by Joomla / template) and we want to search for (in this case) all <img> elements.
Doing this via the DOM is the easiest as it just lists all the <img> elements it finds, doing it via a regex is error prone as you then need to construct a regex (search): an image can be set as <img src="...." > but could also be <img alt="..." src="..."/> and al kind of combinations of "/ ' ending in > or />, etc.
So there is a chance of the regex failing to find and extract the correct information.
That is why I initially thought it was 'brilliant' to use the DOM for finding and replacing the <img> elements....
Until I learned that HTML is 'forgiving' when there are errors in the HTML document: the browser still tries to display the page as best as possible if there are errors: this is a 'good' thing, but not for querying the DOM as that requires correct HTML as otherwise it will give an error.
What I learned is that there are a lot of Joomla sites / templates out there that really mess up the HTML: it displays okay but it is full of error and that results in ochResponsiveImages to NOT find all the images... So I thought let's first read the HTML and use the DOM to save it and by doing that produce cleanup HTML.... As it turned out, that in some cases didn't work and mangled badly formatted sites...
So I just implemented regex as second (and now preferred) way to find the images... The cleanup HTML option is still there but should not be used.
So long story short: I tried to fix broken and poorly developed sites and that back-fired
This toggle is still in there for legacy purposes but will eventually be hidden and after that removed from the code.