I generally prefer handling all database operations within my models. It’s cleaner, and allows easier testing. So for instance, within the Article model, I’d just declare a function such as:
public function getImages($limit = 5, $offset = 0)
{
// Relation here to retrieve and return images
}
And then within the view:
foreach ($model->getImages(5) as $image): ?>
<!-- render the image !-->
<?php endforeach; ?>