Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for comma separated srcset values in sef.php
System - SEF does not support comma separated values when processing the srcset attribute so only the first URL is converted. This PR removes srcset from the $attributes array on line 120 and processes instances of the attribute separately, splitting the value by a comma and processing each part individually, then returning the value. For example, ```html <img src="images/responsive/winter.jpg" srcset="images/responsive/winter-hd.jpg 2x,images/responsive/winter-2x.jpg 1.5x,images/responsive/winter.jpg 1x" alt="winter" /> ``` becomes ```html <img src="/images/responsive/winter.jpg" srcset="/images/responsive/winter-hd.jpg 2x,/images/responsive/winter-2x.jpg 1.5x,/images/responsive/winter.jpg 1x" alt="winter" /> ``` whereas before, only the first url in the srcset attribute would have been converted, ie: ```html <img src="/images/responsive/winter.jpg" srcset="/images/responsive/winter-hd.jpg 2x,images/responsive/winter-2x.jpg 1.5x,images/responsive/winter.jpg 1x" alt="winter" /> ``` A more elegant solution may be available, but this one appears to work OK. ### Testing Instructions Create a new article using the following HTML code, or similar. You will need 3 images of different resolutions, or just three different images of any resolution. ```html <img src="images/image1.jpg" srcset="images/image3.jpg 2x,images/image2.jpg 1.5x,images/image1.jpg 1x" alt="" /> ``` ### Expected result The image displays correctly in the browser. ### Actual result With the current sef.php the images will not display correctly in a modern browser. You can check the code using the browser console to see that the srcset values have not all been converted.
- Loading branch information