Hi Rostyslav,
Yes, that would work if you don’t want to just hide the image block.
You would simply need two block elements and set the display rules depending on wp_is_mobile().
So in your case, something like this:
add_filter( 'generate_block_element_display', function( $display, $element_id ) {
if ( wp_is_mobile() ) {
if ( 123 === $element_id ) {
$display = false;
}
} else {
if ( 456 === $element_id ) {
$display = false;
}
}
return $display;
}, 10, 2 );
Kindly replace 123 and 456 with you Elements’ IDs.