Skip to content

Commit aef2b20

Browse files
chore: fix tests
1 parent 0823ba9 commit aef2b20

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

inc/url_replacer.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -227,17 +227,19 @@ private function normalize_image( $url, $original_url, $args, $is_uploaded = fal
227227
}
228228

229229
$is_retina_enabled = $this->settings->get( 'retina_images' ) !== 'disabled';
230-
$max_dimension = max( $args['width'], $args['height'] );
231-
$should_apply_dpr = false;
232-
233-
if ( $is_retina_enabled || ( $max_dimension > 0 && $max_dimension < 150 ) ) {
234-
$should_apply_dpr = true;
235-
}
236-
237-
$should_apply_dpr = apply_filters( 'optml_should_apply_dpr', $should_apply_dpr, $args, $url );
238-
239-
if ( $should_apply_dpr && ! isset( $args['dpr'] ) ) {
240-
$args['dpr'] = 2;
230+
if ( ! $is_retina_enabled) {
231+
$max_dimension = max( $args['width'], $args['height'] );
232+
$should_apply_dpr = false;
233+
234+
if ( $max_dimension > 0 && $max_dimension < 150 ) {
235+
$should_apply_dpr = true;
236+
}
237+
238+
$should_apply_dpr = apply_filters( 'optml_should_apply_dpr', $should_apply_dpr, $args, $url );
239+
240+
if ( $should_apply_dpr && ! isset( $args['dpr'] ) ) {
241+
$args['dpr'] = 2;
242+
}
241243
}
242244

243245
$args = apply_filters( 'optml_image_args', $args, $original_url );

tests/test-lazyload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public function test_lazy_load_preserve_image_size() {
235235
$this->assertNotEquals( $replaced_content, $html );
236236
$this->assertStringNotContainsString( 'q:eco/rt:fill/g:ce', $replaced_content );
237237
$this->assertStringContainsString( '/rt:fill/g:ce', $replaced_content );
238-
$this->assertStringContainsString( '/w:96/h:96/q:eco/ig:avif/http://example.org/', $replaced_content );
238+
$this->assertStringContainsString( '/w:96/h:96/q:eco/ig:avif/dpr:2/http://example.org/', $replaced_content );
239239

240240
}
241241

0 commit comments

Comments
 (0)