Skip to content

Commit a54e771

Browse files
committed
load when plugin is active, add comments
1 parent 9af5554 commit a54e771

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/block-components/image/image-optimizer-polyfill.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
import domReady from '@wordpress/dom-ready'
55

66
class ImageOptimizerPolyfill {
7+
/**
8+
* This script is loaded when EWWW Image Optimizer plugin is activated
9+
* If Easy IO setting is activated for EWWW Image Optimizer plugin, dynamic images becomes blurry.
10+
* This script fixes the issue by removing the &fit parameter from the srcset and src attributes
11+
*/
712
init = () => {
813
const imgs = document.querySelectorAll( '.stk-block img' )
914
imgs.forEach( img => {

src/block-components/image/index.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
if ( ! function_exists( 'stackable_load_image_optimizer_polyfill_frontend_script' ) ) {
99
function stackable_load_image_optimizer_polyfill_frontend_script( $block_content, $block ) {
10+
// If Easy IO setting is activated for EWWW Image Optimizer, dynamic images becomes blurry.
11+
// Load the script to fix the issue.
1012
if ( ! is_admin() ) {
1113
wp_enqueue_script(
1214
'stk-frontend-image-optimizer-polyfill',
@@ -21,7 +23,8 @@ function stackable_load_image_optimizer_polyfill_frontend_script( $block_content
2123
}
2224
}
2325

24-
if ( ! is_admin() ) {
26+
if ( ! is_admin() && is_plugin_active( 'ewww-image-optimizer/ewww-image-optimizer.php' )) {
27+
// Load the script in the frontend if EWWW Image Optimizer is active.
2528
add_action( 'stackable/enqueue_scripts', 'stackable_load_image_optimizer_polyfill_frontend_script', 10, 2 );
2629
}
2730
}

0 commit comments

Comments
 (0)