Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function dm_filter_wpseo_sitemap_urlimages($images, $post_id) {
- $post = get_post($post_id);
- if (is_object($post)) {
- $content = $post->post_content;
- # Parse Divi Image modules
- preg_match_all('/\[et_pb_image [^]]*]/', $content, $divi_im_images);
- foreach ($divi_im_images[0] as $divi_im_image) {
- # Add the image to the sitemap
- preg_match('/src="([^"]*)"/', $divi_im_image, $src);
- preg_match('/title_text="([^"]*)"/', $divi_im_image, $title);
- preg_match('/alt="([^"]*)"/', $divi_im_image, $alt);
- $images[] = array('src' => $src[1], 'title' => $title[1], 'alt' => $alt[1]);
- }
- # Parse Divi Blurb modules
- preg_match_all('/\[et_pb_blurb [^]]*]/', $content, $divi_bm_images);
- foreach ($divi_bm_images[0] as $divi_bm_image) {
- if (preg_match('/image="([^"]*)"/', $divi_bm_image, $image)) {
- # If the blurb has an image, add it to the sitemap
- preg_match('/title="([^"]*)"/', $divi_bm_image, $title);
- preg_match('/alt="([^"]*)"/', $divi_bm_image, $alt);
- $images[] = array('src' => $image[1], 'title' => $title[1], 'alt' => $alt[1]);
- }
- }
- # Parse Divi Image Gallery modules
- preg_match_all('/\[et_pb_gallery [^]]*]/', $content, $divi_igm_images);
- foreach ($divi_igm_images[0] as $divi_im_image) {
- # Add the image to the sitemap
- preg_match('/src="([^"]*)"/', $divi_im_image, $src);
- preg_match('/title_text="([^"]*)"/', $divi_im_image, $title);
- preg_match('/alt="([^"]*)"/', $divi_im_image, $alt);
- $images[] = array('src' => $src[1], 'title' => $title[1], 'alt' => $alt[1]);
- }
- }
- return $images;
- }
- add_filter('wpseo_sitemap_urlimages', 'dm_filter_wpseo_sitemap_urlimages', 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement