Skip to content

Commit 1ef55b5

Browse files
committed
enhance image dimension handling in Optml_Tag_Replacer
1 parent 45fa436 commit 1ef55b5

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

.distignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,7 @@ tailwind.config.js
4040
phpstan.neon
4141
development.php
4242
playwright.config.ts
43-
test-results
43+
test-results
44+
wp-scripts.config.js
45+
README.md
46+
CHANGELOG.md

inc/tag_replacer.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,15 @@ public function filter_image_src_get_dimensions( $dimensions, $image_src, $image
8585
return $dimensions;
8686
}
8787
$sizes = Optml_App_Replacer::image_sizes();
88-
88+
if ( OPTML_DEBUG ) {
89+
do_action( 'optml_log', 'filter_image_src_get_dimensions: ' . $image_src . ' ' . $width . ' ' . $height . ' ' . print_r( $image_meta, true ) );
90+
}
91+
if ( $width === 'auto' && $height === 'auto' && isset( $image_meta['width'], $image_meta['height'] ) ) {
92+
return [
93+
$image_meta['width'],
94+
$image_meta['height'],
95+
];
96+
}
8997
// If this is an image size. Return its dimensions.
9098
foreach ( $sizes as $size => $args ) {
9199
if ( (int) $args['width'] !== (int) $width ) {

0 commit comments

Comments
 (0)