aceextensions/module-imageoptimizer 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aceextensions/module-imageoptimizer

Composer 安装命令:

composer require aceextensions/module-imageoptimizer

包简介

Image Optimizer module for Magento 2. Adds WebP and AVIF support and enforces ImageMagick.

README 文档

README

A premium, high-performance image optimization suite for Magento 2 that brings modern image formats (WebP, AVIF, SVG) and intelligent lazy-processing to your storefront.

🌟 Key Features

🖼️ Modern Image Format Support

  • WebP & AVIF Generation: Automatically serves ultra-compressed WebP and AVIF images to modern browsers, reducing page weight by up to 80%.
  • SVG Upload Support: Enables secure upload and display of SVG vector graphics in product galleries, category banners, and CMS pages.
  • Enhanced Media Gallery: Extends the Magento Admin to support modern formats across Product Images, Category Attributes, and the WYSIWYG Media Gallery.

🚀 Performance Breakthroughs

  • Near-Zero Rendering Delay: Revolutionizes image processing by deferring physical file generation from the initial page request to pub/get.php. This ensures near-instant TTFB (Time to First Byte).
  • Graceful Nativization: Intelligently handles source images that are natively WebP or PNG without forcing unnecessary JPEG conversions.
  • Lazy Materialization: Images are generated only when requested by the browser. If a user never scrolls to an image, it is never processed, saving CPU and disk cache.

🛠️ Technical Excellence

  • PHP 8.1+ Optimized: Fully modern codebase adhering to Magento 2 coding standards, strict typing, and PHP 8+ features.
  • ImageMagick Enforcement: Intelligently hooks into the Magento Admin to warn administrators and enforce the use of ImageMagick over GD2 for superior modern format support.
  • Pure PHP Implementation: Operates entirely within the PHP environment, requiring no external binaries or complex proxy configurations for standard operation.

📦 Installation via Composer (Packagist)

The recommended way to install this extension is via Composer.

composer require aceextension/module-imageoptimizer
bin/magento module:enable Aceextension_ImageOptmizer
bin/magento setup:upgrade
bin/magento cache:clean

⚙️ Configuration

Available under Stores > Configuration > Aceextension > Image Optimizer:

  • Module Enabled: The master switch for the module's validation and processing logic.
  • Replace Catalog Images with Modern Formats: Toggles the automated URL rewriting on the frontend.
  • Catalog Output Format: Select between WebP and AVIF for frontend output.
  • Enable Debug Logging: Log detailed conversion and processing events to var/log/system.log.

General Configuration

🏗 Architecture Overview

The module utilizes a Lazy Materialization pattern:

  1. URL Hijacking: Intercepts URL generation and rewrites .jpg/.png extensions to .webp.
  2. Processing Bypass: Stops Magento from physically creating the resized file during the initial page request.
  3. On-Demand Processing: When the browser requests the missing .webp file:
    • Nginx routes the request to pub/get.php.
    • Our MediaPlugin intercepts the request.
    • The plugin generates the required source image and instantly converts it to WebP/AVIF.
    • The optimized image is served with correct headers.

Frontend WebP Rendering

📋 Compatibility

  • Magento: 2.4.4 / 2.4.5 / 2.4.6 / 2.4.7+
  • PHP: 8.1 / 8.2 / 8.3
  • Graphics Library: ImageMagick (Strongly Recommended & Enforced via Admin UI Warning)
  • Note: This module utilizes safe PHP Reflection on Magento\Framework\Image\Adapter\Gd2 and Magento\MediaStorage\App\Media to enable modern format generation without core file modification.

📄 Recent Changes (Hardening)

The following security and stability improvements were implemented in the recent release:

  • Harden AVIF handling: Added guards for imageavif and imagecreatefromavif, ensuring graceful fallback to WebP if the server environment lacks native AVIF support.
  • SVG security: Introduced an enable_svg configuration toggle to whitelist SVG uploads and implemented an aroundOpen plugin to prevent backend raster adapters from attempting to process vector graphics.
  • Reflection resilience: Documented target Magento versions and introduced a "log once" mechanism for reflection failures to avoid log noise while maintaining visibility.
  • Centralized URL rewriting: Consolidated all URL replacement logic into a single idempotent helper method to ensure consistent behavior across all frontend plugins.
  • Admin UX: Added a Diagnostics report in the Store Configuration panel to provide instant visibility into PHP-GD/Imagick format capabilities.

📄 License

Copyright (c) 2019 Aceextensions Extensions (http://aceextensions.com)

aceextensions/module-imageoptimizer 适用场景与选型建议

aceextensions/module-imageoptimizer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8 次下载、GitHub Stars 达 2, 最近一次更新时间为 2026 年 02 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 aceextensions/module-imageoptimizer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 aceextensions/module-imageoptimizer 我们能提供哪些服务?
定制开发 / 二次开发

基于 aceextensions/module-imageoptimizer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 8
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 30
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: OSL-3.0
  • 更新时间: 2026-02-23