If your structure is like in your example you can save one of the loops by directly looping over $query['images']:
if (!empty($query['images'])) {
foreach((array) $query['images'] as $image) {
$html .= '<img src="' . $image['image'] . '" alt="" />';
}
}