Skip to content

Commit

Permalink
Avoid mobile breakpoint
Browse files Browse the repository at this point in the history
* Already handled by default case.
  • Loading branch information
Inwerpsel committed Apr 25, 2022
1 parent 5c09438 commit 13d5c35
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions planet4-gutenberg-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,11 +432,6 @@ function ( $std_class_object ) {
'screen' => 600,
'width' => '540px',
],
[
'screen' => 576,
'width' => '540px',
'collapse' => true,
],
];

add_filter(
Expand All @@ -455,16 +450,16 @@ function ( $block_content, $block, WP_Block $instance ) use ( $breakpoints ) {

$sizes = array_map(
function ( $breakpoint ) use ( $column_count ) {
$screen = $breakpoint['screen'];
$container = $breakpoint['width'];
$column_count = isset( $breakpoint['collapse'] ) ? 1 : $column_count;
$screen = $breakpoint['screen'];
$container = $breakpoint['width'];
$cols_minus_one = $column_count - 1;

return "(min-width: ${screen}px) calc(($container / $column_count) - 1.25em * ($column_count - 1))";
return "(min-width: ${screen}px) calc(($container / $column_count) - 1.25em * $cols_minus_one)";
},
$breakpoints
);

$sizes_attr = 'sizes="' . implode( ', ', $sizes ) . ', calc(100vw - 24px)"';
$sizes_attr = 'sizes="' . implode( ', ', array_merge($sizes, ['calc(100vw - 24px)']) ) . '"';

// Assume all images are full width in a container.
$block_content = preg_replace( '/sizes=".*"/', $sizes_attr, $block_content );
Expand Down

0 comments on commit 13d5c35

Please sign in to comment.