Yireo_NextGenImages
This module adds next-gen image support to Magento 2. Please note that this is a base extension for other extensions to use. See Yireo_Webp2 for details.
WARNING: If you are using Hyva and want to use the latest version of this module, remove Hyva_YireoNextGenImages.
Development
This module features some settings and info panels in the Magento Store Configuration. But the major feature is a plugin on the Layout that scans for HTML <img/> tags to convert them into <picture/> tags with sources for alternative image formats.
A module Foo_Bar could add a etc/di.xml file to add a new convertor (a class implementing \Yireo\NextGenImages\Convertor\ConvertorInterface) to the convertor listing:
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Yireo\NextGenImages\Convertor\ConvertorListing"> <arguments> <argument name="convertors" xsi:type="array"> <item name="foobar" xsi:type="object">Foo\Bar\Convertor</item> </argument> </arguments> </type> </config>
FAQ
Can I skip lazy loading of images?
Yes, just add fetchpriority="high" to the image HTML of your choice.
Can I call upon the convertor directly?
Yes, you can. You can inject the class Yireo\NextGenImages\Image\ImageCollector as a block argument via the XML layout (or alternatively use the LokiComponents $viewModelFactory or the Hyva $viewModels to instantiate it) and then call upon it as follows:
$images = $this->imageCollector->collect($imageUrl);
Roadmap
- Move CLI into separate module
- Move frontend into separate module
- Create GraphQL support
- Add more next gen image formats
- JPEG 2000
- HEIC
- AVIF
- JPEG XL
- WebP2
Current status
Support
For getting support, create an Issue under the following project URL:
https://github.com/yireo/Yireo_NextGenImages
Configuration Options
The following options of this module can be configured via the Store Configuration:
yireo_nextgenimages/settings/funding
yireo_nextgenimages/settings/enabled
yireo_nextgenimages/settings/debug
yireo_nextgenimages/settings/log
yireo_nextgenimages/settings/convert_images
yireo_nextgenimages/settings/convert_css_backgrounds
yireo_nextgenimages/settings/target_directory
yireo_nextgenimages/settings/cache_directory
yireo_nextgenimages/settings/hash
yireo_nextgenimages/settings/convert_on_save
yireo_nextgenimages/settings/lazy_loading
yireo_nextgenimages/settings/php_version
yireo_nextgenimages/settings/module_version
yireo_nextgenimages/settings/gd
Module Dependencies
The following dependencies are declared in the module its `etc/module.xml` file:
Magento_AdminNotification
Magento_Backend
Magento_Catalog
Magento_CatalogInventory
Magento_Checkout
Magento_Cms
Magento_Config
Magento_ConfigurableProduct
Magento_Cron
Magento_Csp
Magento_Customer
Magento_Directory
Magento_Eav
Magento_Indexer
Magento_LayeredNavigation
Magento_MediaStorage
Magento_Msrp
Magento_PageCache
Magento_Payment
Magento_Quote
Magento_RemoteStorage
Magento_Robots
Magento_Rule
Magento_Sales
Magento_SalesSequence
Magento_Sitemap
Magento_Store
Magento_Swatches
Magento_Theme
Magento_Variable
Yireo_CspUtilities
Yireo_IntegrationTestHelper
Composer details
Yireo_NextGenImagesyireo/magento2-next-gen-images
ext-dom: *
ext-gd: *
ext-pcre: *
magento/framework: ^101.0.1|^101.1|^102.0|^103.0
magento/module-backend: ^100.0|^101.0|^102.0
magento/module-catalog: ^100.0|^101.0|^102.0|^103.0|^104.0
magento/module-config: ^101.0
magento/module-configurable-product: ^100.0
magento/module-page-cache: ^100.0
magento/module-remote-storage: ^100.4
magento/module-store: ^100.0|^101.0
magento/module-swatches: ^100.0
php: >=8.2 <8.6
psr/log: ^1 || ^2 || ^3
yireo/magento2-csp-utilities: ^1.0
Releases
| 0.5.16 | 23 October 2026 |
| 0.5.15 | 23 October 2026 |
| 0.5.14 | 23 October 2026 |
| 0.5.13 | 23 October 2026 |
| 0.5.12 | 23 October 2026 |
| 0.5.11 | 23 October 2026 |
| 0.5.10 | 23 October 2026 |
| 0.5.9 | 23 October 2026 |
| 0.5.8 | 23 October 2026 |
| 0.5.7 | 23 October 2026 |
| 0.5.6 | 23 October 2026 |
| 0.5.5 | 23 October 2026 |
| 0.5.3 | 23 October 2026 |
| 0.5.2 | 23 October 2026 |
| 0.5.0 | 23 October 2026 |
| 0.4.1 | 23 October 2026 |
| 0.4.0 | 23 October 2026 |
| 0.3.18 | 23 October 2026 |
| 0.3.17 | 23 October 2026 |
| 0.3.16 | 23 October 2026 |
| 0.3.15 | 23 October 2026 |
| 0.3.14 | 23 October 2026 |
| 0.3.13 | 23 October 2026 |
| 0.3.12 | 23 October 2026 |
| 0.3.11 | 23 October 2026 |
| 0.3.10 | 23 October 2026 |
| 0.3.9 | 23 October 2026 |
| 0.3.8 | 23 October 2026 |
| 0.3.7 | 23 October 2026 |
| 0.3.6 | 23 October 2026 |
| 0.3.5 | 23 October 2026 |
| 0.3.4 | 23 October 2026 |
| 0.3.3 | 23 October 2026 |
| 0.3.2 | 23 October 2026 |
| 0.3.1 | 23 October 2026 |
| 0.3.0 | 23 October 2026 |
| 0.2.13 | 23 October 2026 |
| 0.2.12 | 23 October 2026 |
| 0.2.11 | 23 October 2026 |
| 0.2.10 | 23 October 2026 |
| 0.2.9 | 23 October 2026 |
| 0.2.8 | 23 October 2026 |
| 0.2.7 | 23 October 2026 |
| 0.2.6 | 23 October 2026 |
| 0.2.5 | 23 October 2026 |
| 0.2.4 | 23 October 2026 |
| 0.2.3 | 23 October 2026 |
| 0.2.2 | 23 October 2026 |
| 0.2.1 | 23 October 2026 |
| 0.2.0 | 23 October 2026 |
Changelog
[0.5.16] - 18 October 2026
Fixed
- Fall back to first srcset image without default descriptor
- Keep img tags with a ">" in an attribute intact
- Detect target format per convertor
- Download each remote image only once per request
- Map paths when local folders do not exist
- Handle remote errors and staged files in file plugin
- Remove duplicate import in picture template
- Add test coverage for remote storage support (PR #95)
- Set dependency with
symfony/consoleto v5, v6 or v7 - Remove background of sponsoring box for Nebula compat
- Swatches fix for category pages
- WIP for better support configurable options
- Add support for converting pictures with src-sets
[0.5.15] - 22 October 2025
Fixed
- Fix PHP call
- Add helper-method for fetching GdImage
[0.5.14] - 24 July 2025
Fixed
- Add
Yireo_IntegrationTestHelperas dep - Allow replacing images in AJAX (AHAH) requests as well
- Add PHP 8.4 testing
[0.5.13] - 23 April 2025
Fixed
- Fix issue with
str_containsunder PHP 7.4 - Fixed implicitly declared nullable arguments, improves compatibility with PHP 8.4
[0.5.12] - 19 February 2025
Fixed
- Issue with
LIBXML_HTML_NOIMPLIEDand templates with multiple roots Yireo_Webp2#175
[0.5.11] - 11 February 2025
Fixed
- Fix possible warning with DOM loading
[0.5.10] - 11 December 2024
Fixed
- Fix issues from #83
- Better integration tests
[0.5.9] - 4 December 2024
Fixed
- Masks and unmasks angle brackets quotes #83 @wilfriedwolf
- Command next-gen-images:convert not working if images are on shared folders #80 @wilfriedwolf
[0.5.8] - 24 October 2024
Fixed
- Add funding
[0.5.7] - 26 August 2024
Fixed
- Wrong composer dependencies
[0.5.6] - 23 August 2024
Fixed
- Cast string as return type
[0.5.5] - 23 August 2024
Fixed
- Add CSP nonces to inline scripts
[0.5.4] - 9 August 2024
Fixed
- Only re-use limited set of HTML attributes for source-tags #78
[0.5.3] - 22 May 2024
Fixed
- Make sure that HTML attribute values with double-quotes are still working #77
[0.5.2] - 4 April 2024
Fixed
- Compatibility with Magento >=2.4.7-beta3
[0.5.1] - 27 February 2024
Fixed
- Add warning about
Hyva_YireoNextGenImagesbecause docs are not read - Check for image extension in entire url instead of only at the end #72 @jesperingels
- Remove data-src and data-srcset from original attributes in sources
- Remove all whitespaces in image output
- Fix broken integration tests due to modified constructor
- Add relative-path of source image to target-path if target is cache-folder #62 @rommelfreddy
[0.5.0] - 22 September 2023
Added
- Dispatch all-purpose Hyva
gallery-initevent to modify component data - Allow to configure skipped layout handles via DI type of
ShouldModifyOutput
Fixed
- Fix issue where image is not replaced with
imgtag opening plus newline - Field in admin is
cache_directory_pathinstead ofcache_directory#154 - Quick hack for supporting
/pub/in URLs
[0.4.1] - 15 August 2023
Fixed
- Make sure only PNG and JPG are being picked up
Added
- Moved Hyva compatibility module features into this module, deprecating the compat mod
[0.4.0] - 16 March 2023
Fixed
- Fixed HTTPS links being reset to HTTP links due to "normalization"
- Simplify normalization without HTTP/HTTPS reset
Added
- Option
convert_css_backgroundsto convert images in CSS backgrounds as well #25 (@rommelfreddy)
[0.3.18] - 05 March 2023
Fixed
- Fix deprecated dynamic property
[0.3.17] - 05 March 2023
Fixed
- Fix PHP 7.3 issue
- Bump composer requirement to PHP 7.3
[0.3.16] - 01 March 2023
Fixed
- Make image cache path
/media/nextgenimages/configurable
[0.3.15] - 28 February 2023
Fixed
- Remove duplicate source that matches original image
- Also convert
data-srcwhen present - Support URLs from multiple Store Views
- Ajax response plugin gets incorrect gallery images #55 @joe-vortex
[0.3.14] - 27 February 2023
Fixed
- Prevent
imgin script from being parsed #133
[0.3.13] - 27 February 2023
Fixed
- Fix for PHP 8.2 deprecated
mb_convert_encoding#57 @hostep
[0.3.12] - 10 January 2023
Fixed
- Remove loading="lazy" when fetchpriority="high" is present #53 @jesperingels
[0.3.11] - 24 October 2022
Fixed
- Error 'Argument #1 () must not be empty' on PHP 8 #36 @khoimm92
[0.3.10] - 3 July 2022
Fixed
- Don't display image timestamp if no image is there
- Allow for multiple img tags on a row
- Switch from complex regex to easier DOMDocument search
- Issue with integration tests and Monolog 2.7
- Add GitHub Actions composer cacheq
[0.3.9] - 29 June 2022
Fixed
- Normalize base URL as well
- Change html_entity_decode into escaper for PHPCS
[0.3.8] - 29 June 2022
Fixed
- Make sure to keep HTTPS URLs for media intact
- Convert static files into static URLs properly
[0.3.7] - 29 June 2022
Fixed
- Normalized URLs don't match anymore with media URL and static URL (WebP #122)
[0.3.6] - 27 June 2022
Fixed
- Handle URLs starting without protocol (//) in a better way (#34)
[0.3.5] - 12 June 2022
Fixed
- Strip query string from source image URL (@theuargb)
[0.3.4] - 7 June 2022
Fixed
- Make sure non-existing sources don't throw exceptions
[0.3.3] - 2 June 2022
Fixed
- Do not edit gallery JSON when module is disabled
[0.3.2] - 21 May 2022
Fixed
- Fix URL-to-file conversion for URL-decoded URLs
- Respect native lazy loading attribute #29 (@pointia)
[0.3.1] - 19 May 2022
Fixed
- Set sane defaults for all configuration values
- Check if extension is enabled for plugin #30 (@artbambou)
Added
- Beautify console output
[0.3.0] - 4 May 2022
Fixed
- Same WebP image for example.jpg and example.jpeg
- Improve translating static file URLs into filenames
- Add event observer to make sure blocks with non-zero TTL are parsed when FPC is enabled
- Fix issues with Product Swatches
Added
- Various unit tests
- Live testing for better testing
- Moved AJAX plugin for swatches from WebP extension to NextGenImages
- New config option for target directory
- New config option for adding an unique hash for target images
- Implement hash when creating target images
[0.2.13] - 10 December 2021
Fixed
- isNewerThan method is not reached when the converted image already exists (@peteracs)
[0.2.12] - 10 November 2021
Added
- Allow file driver interface to be overwritten
[0.2.11] - 26 October 2021
Fixed
- Make sure non-self-breaking sources don't break
[0.2.10] - 17 August 2021
Fixed
- Prevent file check from reading whole file (performance issue)
[0.2.9] - 17 August 2021
Fixed
- Fatal Error on swatches AJAX call
Removed
- DummyConvertor with DI preference
- UrlReplacer used only in CorrectImagesInAjaxResponse
[0.2.8] - 17 August 2021
Fixed
- Wrap exceptions so they don't appear in frontend
- Prevent non-existing files from throwing NotFoundException
[0.2.7] - 13 August 2021
Fixed
- Be more helpful when non-existing image is used in convert command
- Make sure UrlConvertor throws error properly (@Quazz)
[0.2.6] - 13 August 2021
Fixed
- Exception was supplied
Phraseinstead of string
[0.2.5] - 12 August 2021
Fixed
- Remove debugging info
[0.2.4] - 12 August 2021
Fixed
- Make sure plugin ConvertAfterImageSave still respects original return value
Added
- Additional debug options for CLI command
- Support for media URL different from base URL (like CDNs)
[0.2.3] - 7 July 2021
Fixed
- Add current store to all methods
- Make sure ConvertorListing works even though no convertor is available
- Hide all other fields if setting "Enabled" is set to 0
- Make sure plugins are off when module is configured to be disabled
[0.2.2] - 29 June 2021
Fixed
- Make sure CLI converts images with their absolute path
- Only convert image URLs matching the Magento base URL [@tdgroot]
[0.2.1] - 9 March 2021
Fixed
- Fix Dummy convertor to prevent compilation error
[0.2.0] - 9 March 2021
Added
- New option to try to convert on saving
- Add console command for converting images manually
- Add command to test for URIs quickly
- Update convertor to make second arg optional
[0.1.1] - 15 February 2021
Fixed
- Fix composer version
- Fix word "Logging" in config options
[0.1.0] - 15 February 2021
Added
- Enhance debugger with logging option
- Add logging with every exception
[0.0.6] - 7 January 2021
Fixed
- Reimplement
data-src(PR 51 from theYireo_Webp2module)
[0.0.5] - 3 December 2020
Fixed
- Add dummy convertor with DI preference
- Replace all WebP deps with NextGenImages deps
[0.0.4] - 2 December 2020
Fixed
- Re-add dep with WebP2 in controller
[0.0.3] - 2 December 2020
Fixed
- Remove deps with WebP2 module
- Add missing Browser class
[0.0.2] - 30 November 2020
Added
- Methods to added to ConvertorInterface
Removed
- Remove duplicate DI.xml (and add docs for this)
[0.0.1] - 30 November 2020
Added
- Initial release together with Yireo WebP2