@@ -200,7 +200,11 @@ function auto_sizes_calculate_better_sizes( int $id, $size, string $align, int $
200
200
201
201
case 'wide ' :
202
202
$ layout_width = auto_sizes_get_layout_width ( 'wide ' );
203
- if ( str_ends_with ( $ layout_width , 'px ' ) ) {
203
+ if (
204
+ str_ends_with ( $ layout_width , 'px ' ) &&
205
+ ( $ container_relative_width > 0.0 ||
206
+ $ container_relative_width < 1.0 )
207
+ ) {
204
208
// First remove 'px' from width.
205
209
$ layout_width = str_replace ( 'px ' , '' , $ layout_width );
206
210
// Convert to float for better precision.
@@ -220,7 +224,11 @@ function auto_sizes_calculate_better_sizes( int $id, $size, string $align, int $
220
224
* If the layout width is in pixels, we can compare against the image width
221
225
* on the server. Otherwise, we need to rely on CSS functions.
222
226
*/
223
- if ( str_ends_with ( $ layout_width , 'px ' ) ) {
227
+ if (
228
+ str_ends_with ( $ layout_width , 'px ' ) &&
229
+ ( $ container_relative_width > 0.0 ||
230
+ $ container_relative_width < 1.0 )
231
+ ) {
224
232
// First remove 'px' from width.
225
233
$ layout_width = str_replace ( 'px ' , '' , $ layout_width );
226
234
// Convert to float for better precision.
@@ -337,7 +345,10 @@ function auto_sizes_filter_render_block_context( array $context, array $block, ?
337
345
}
338
346
339
347
// Multiply with parent's width if available.
340
- if ( isset ( $ parent_block ->context ['container_relative_width ' ] ) ) {
348
+ if (
349
+ isset ( $ parent_block ->context ['container_relative_width ' ] ) &&
350
+ ( $ current_width > 0.0 || $ current_width < 1.0 )
351
+ ) {
341
352
$ context ['container_relative_width ' ] = $ parent_block ->context ['container_relative_width ' ] * $ current_width ;
342
353
} else {
343
354
$ context ['container_relative_width ' ] = $ current_width ;
0 commit comments