public function get_images($post)
{
$images = array();
if (!is_object($post)) {
return $images;
}
$thumbnail_id = get_post_thumbnail_id($post->ID);
if ($thumbnail_id) {
$src = $this->get_absolute_url($this->image_url($thumbnail_id));
$alt = get_post_meta($thumbnail_id, '_wp_attachment_image_alt', true);
$title = get_post_field('post_title', $thumbnail_id);
$images[] = $this->get_image_item($post, $src, $title, $alt);
}
$unfiltered_images = $this->parse_html_images($post->post_content);
foreach ($unfiltered_images as $image) {
$images[] = $this->get_image_item($post, $image['src'], $image['title'], $image['alt']);
}
foreach ($this->parse_galleries($post->post_content, $post->ID) as $attachment) {
$src = $this->get_absolute_url($this->image_url($attachment->ID));
$alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
$images[] = $this->get_image_item($post, $src, $attachment->post_title, $alt);
}
if ('attachment' === $post->post_type && wp_attachment_is_image($post)) {
$src = $this->get_absolute_url($this->image_url($post->ID));
$alt = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
$images[] = $this->get_image_item($post, $src, $post->post_title, $alt);
}
foreach ($images as $key => $image) {
if (empty($image['src'])) {
unset($images[$key]);
}
}
/**
* Filter images to be included for the post in XML sitemap.
*
* @param array $images Array of image items.
* @param int $post_id ID of the post.
*/
$images = apply_filters('wpseo_sitemap_urlimages', $images, $post->ID);
return $images;
}