keycdn / cache-enabler

A lightweight caching plugin for WordPress that makes your website faster by generating static HTML files.
https://wordpress.org/plugins/cache-enabler/
123 stars 46 forks source link

update and fix WebP URL conversion #125

Closed coreykn closed 4 years ago

coreykn commented 4 years ago

Update Cache_Enabler_Disk::_create_files():

Update Cache_Enabler_Disk::_convert_webp() to start the conversion as soon as one image is found instead of counting them.

Fix Cache_Enabler_Disk::_image_path() to return correct image path if installation is in a subdirectory. This issue was introduced in version 1.4.8 when allowing images in any directory to be replaced instead of images only in the uploads directory (PR #116). Previously the subdirectory name was being duplicated (from the ABSPATH and the received $image_url). The leading slash in the $image_url_path variable will always be trimmed in case a relative URL is provided without a leading slash. The first directory is then taken as the potential installation directory (e.g. wordpress/). If the first directory is in the ABSPATH it is removed from the ABSPATH (e.g. /path/to/public/wordpress/ would become /path/to/public/). The $image_path is then created by concatenating the potentially updated ABSPATH and $image_url_path (e.g. /path/to/public/wordpress/wp-content/uploads/example.jpg).