PluginProbe
WP-Stateless – Google Cloud Storage / 2.3.0
WP-Stateless – Google Cloud Storage v2.3.0
4.4.3 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.3.0 2.3.1 2.3.2 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 All 62 releases
wp-stateless / lib / classes / compatibility / ewww.php

ewww.php in WP-Stateless – Google Cloud Storage 2.3.0, at lib/classes/compatibility/ewww.php

58 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: EWWW Image Optimizer
4 * Plugin URI: https://ewww.io/
5 *
6 * Compatibility Description: Enables support for these EWWW Image Optimizer Image Optimizer features
7 *
8 * https://github.com/wpCloud/wp-stateless/issues/371
9 */
10
11 namespace wpCloud\StatelessMedia {
12
13 if(!class_exists('wpCloud\StatelessMedia\EWWW')) {
14
15 class EWWW extends ICompatibility {
16 protected $id = 'ewww';
17 protected $title = 'EWWW Image Optimizer';
18 protected $constant = 'WP_STATELESS_COMPATIBILITY_EWWW';
19 protected $description = 'Enables limited support for EWWW Image Optimizer in CDN mode.';
20 protected $plugin_file = ['ewww-image-optimizer/ewww-image-optimizer.php'];
21
22 public function module_init($sm){
23 // add_filter( 'ewww_image_optimizer_pre_optimization', array($this, 'pre_optimization'), 10, 3 );
24 add_action( 'ewww_image_optimizer_post_optimization', array($this, 'post_optimization'), 10, 3 );
25 }
26
27 /**
28 * Try to restore images before compression
29 *
30 */
31 public function pre_optimization( $file, $type, $fullsize ) {
32 // wp_stateless_file_name filter will remove the basedir from the path and prepend with root dir.
33 $name = apply_filters( 'wp_stateless_file_name', $file);
34 do_action( 'sm:sync::syncFile', $name, $file, true, array('stateless' => false, 'download' => true));
35 }
36
37 /**
38 * If image size not exist then upload it to GS.
39 *
40 */
41 public function post_optimization($file, $type, $fullsize){
42 // wp_stateless_file_name filter will remove the basedir from the path and prepend with root dir.
43 $name = apply_filters( 'wp_stateless_file_name', $file);
44 do_action( 'sm:sync::syncFile', $name, $file, true);
45
46 // if($fullsize && file_exists($file . '.bak'))
47 // do_action( 'sm:sync::syncFile', $name . '.bak', $file . '.bak', true);
48
49 if(file_exists($file . '.webp'))
50 do_action( 'sm:sync::syncFile', $name . '.webp', $file . '.webp', true);
51 }
52
53 }
54
55 }
56
57 }
58