wp-rocket
wp-rocket copied to clipboard
Add htaccess redirect rules for WebP images
Description
If the WebP Compatibility is enabled, the website serves only WebP images that are directly linked from the HTML source of the page. It doesn’t serve WebP equivalents of images:
- linked from CSS files
- linked from JS files
- linked from encoded JS data inside HTML source
- with URLs dynamically loaded via API call or other means
This pull request adds extra redirect rules that will be placed in the .htaccess
file. These rules will results in loading WebP equivalents of JPG, PNG and BMP images if they exists on the filesystem.
Request for feedback
- Is there a reason why this wasn’t already part of the plugin?
- Were there some concerns regarding this solution?
Type of change
- Enhancement (non-breaking change which improves an existing functionality).
Checklists
Generic development checklist
- [x] My code follows the style guidelines of this project, with adapted comments and without new warnings.
- [x] The CI passes locally with my changes (including unit tests, integration tests, linter).
Test summary
- [x] I have performed a self-review of my own code
- [x] Existing unit tests pass locally with my changes
- [x] I triggered all changed lines of code at least once without new errors/warnings/notices.