I did it as follows:
<ul class="block-list-grid">
<?php
// maximum of a hundred blocks
for ($i = 0; $i < 100; $i++) {
if (!empty($block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('block_' . $i)->toHtml())):?>
// have corresponding image for each block and iterating over them
<li class="block-list-image">
<div class="block-list-grid-item" data-option="<?= $i ?>">
<?= $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('img_block_' . $i)->toHtml(); ?>
</div>
</li>
<?php
endif;
}
?>
</ul>
<?php
for ($i = 0; $i < 100; $i++) {
if (!empty($block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('block_' . $i)->toHtml())):?>
<div class="story-items">
<div class="pop-up-mtm" data-option="<?= $i ?>">
<div class="pop-up-text mtm-text-pop-up">
<span class="close-popup-mtm"></span>
<?= $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('block_' . $i)->toHtml(); ?>
</div>
</div>
</div>
<?php
endif;
}
?>
So as you can see, I made blocks starting with 'img_block_', which contain images. The next loop that iterates over 'block_' is the content in the pop ups. When clicked on for instance the image of 'img_block_1', the popup with content of 'block_1' will show up.
A relative small piece of simple code.