loadHTML($content); $images = $dom->getElementsByTagName('img'); foreach ($images as $image) { if($image->getAttribute('data-id')) { $id = $image->getAttribute('data-id'); } else { $class_pieces = explode("-", $image->getAttribute('class')); $id = end($class_pieces); } // Format for lightbox wants an object $title = get_the_title($id) . "\n \n" . get_post($id)->post_content; $parse_images[$id] = [ 'src' => $image->getAttribute('src'), 'alt' => $image->getAttribute('alt'), 'title' => $title ]; } return $parse_images; } ?>