I've found that the markup seems to differ on some sites.
Usually, the code from fix-gutenberg-image.php
resolves this, but if that doesn't work for you, please try the code from fix-gutenberg-image-2.php
.
The code can be added to the site using a snippets type plugin, such as WPCodeBox.