Add WebP conversion and garbage collection to MLS plugin

Image handling improvements:
- Convert PNG and images >500KB to WebP format
- Resize images wider than 1600px maintaining aspect ratio
- Check for .webp version before falling back to original
- WebP quality set to 80 (equivalent to JPEG 90%)

Garbage collection for disk space management:
- New MLS_Garbage_Collector class runs after each sync
- Only active when MLS_GC_DISK_THRESHOLD defined in wp-config
- Deletes image directories older than 24 hours, oldest first
- Stops when free space reaches 5GB or 2GB deleted per run
- Protects recently accessed images from deletion

Documentation:
- Added Garbage Collection section to README
- Updated Features list and File Structure

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Hanson.xyz Dev
2026-01-04 20:48:57 -06:00
parent 25608a5327
commit c2d5b2248d
5 changed files with 777 additions and 20 deletions
@@ -63,6 +63,7 @@ final class MLS_Plugin {
private $image_endpoint;
private $query;
private $cluster;
private $garbage_collector;
/**
* Get single instance
@@ -98,6 +99,7 @@ final class MLS_Plugin {
require_once MLS_PLUGIN_DIR . 'includes/class-mls-query.php';
require_once MLS_PLUGIN_DIR . 'includes/class-mls-cluster.php';
require_once MLS_PLUGIN_DIR . 'includes/class-mls-geo-validator.php';
require_once MLS_PLUGIN_DIR . 'includes/class-mls-garbage-collector.php';
// Activation/Deactivation
require_once MLS_PLUGIN_DIR . 'includes/class-mls-activator.php';
@@ -149,6 +151,7 @@ final class MLS_Plugin {
);
$this->query = new MLS_Query($this->db);
$this->cluster = new MLS_Cluster($this->db);
$this->garbage_collector = new MLS_Garbage_Collector($this->logger);
// Register AJAX handlers
add_action('wp_ajax_mls_get_clusters', array($this, 'ajax_get_clusters'));
@@ -247,6 +250,13 @@ final class MLS_Plugin {
return $this->cluster;
}
/**
* Get Garbage Collector instance
*/
public function get_garbage_collector() {
return $this->garbage_collector;
}
/**
* AJAX handler for getting map clusters
*/