File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -612,6 +612,15 @@ protected function parse_dimensions_from_filename( $src ) {
612
612
if ( $ width && $ height ) {
613
613
return [ $ width , $ height , $ crop ];
614
614
}
615
+ } else {
616
+ $ optimized_args = $ this ->parse_dimension_from_optimized_url ( $ src );
617
+ if ( $ optimized_args [0 ] !== 'auto ' && $ optimized_args [1 ] !== 'auto ' ) {
618
+ return [
619
+ $ optimized_args [0 ] !== 'auto ' ? (int ) $ optimized_args [0 ] : false ,
620
+ $ optimized_args [1 ] !== 'auto ' ? (int ) $ optimized_args [1 ] : false ,
621
+ false ,
622
+ ];
623
+ }
615
624
}
616
625
617
626
return [ false , false , false ];
Original file line number Diff line number Diff line change 9
9
final class Optml_Tag_Replacer extends Optml_App_Replacer {
10
10
use Optml_Normalizer;
11
11
use Optml_Validator;
12
+ use Optml_Dam_Offload_Utils;
12
13
13
14
/**
14
15
* Cached object instance.
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ class Test_Lazyload extends WP_UnitTestCase {
25
25
<img src="http://example.org/wp-content/optimole-wp/assets/img/logo5.gif">
26
26
' ;
27
27
const DAM_IMG_TAG = '<img width="100" height="200" src="https://cloudUrlTest.test/dam:1/w:auto/h:auto/q:auto/id:b1b12ee03bf3945d9d9bb963ce79cd4f/https://test-site.test/9.jpg"> ' ;
28
+ const DAM_IMG_TAG_NO_WIDTH = '<img src="https://cloudUrlTest.test/w:200/h:300/process:20202/q:auto/id:b1b12ee03bf3945d9d9bb963ce79cd4f/https://test-site.test/9.jpg"> ' ;
28
29
public function setUp () : void {
29
30
parent ::setUp ();
30
31
$ settings = new Optml_Settings ();
@@ -575,4 +576,13 @@ public function test_dam_lazyloading() {
575
576
576
577
$ this ->assertStringContainsString ( 'data-opt-src="https://cloudUrlTest.test/w:100/h:200/rt:fill/g:ce/ig:avif/q:mauto/id:b1b12ee03bf3945d9d9bb963ce79cd4f/https://test-site.test/9.jpg" ' , $ replaced_content );
577
578
}
579
+ public function test_dam_lazyloading_no_wh_attributes () {
580
+ add_filter ('optml_lazyload_images_skip ' ,'__return_zero ' );
581
+ Optml_Manager::instance ()->lazyload_replacer ->settings ->update ('lazyload_placeholder ' ,'enabled ' );
582
+ Optml_Manager::instance ()->lazyload_replacer ->init ();
583
+ $ replaced_content = Optml_Manager::instance ()->process_images_from_content ( self ::DAM_IMG_TAG_NO_WIDTH );
584
+ $ svg = Optml_Manager::instance ()->lazyload_replacer ->get_svg_for ( 200 , 300 , 'http://example.org/testimage.png ' );
585
+ $ this ->assertStringContainsString ( $ svg , $ replaced_content );
586
+ remove_filter ('optml_lazyload_images_skip ' ,'__return_zero ' );
587
+ }
578
588
}
You can’t perform that action at this time.
0 commit comments