wordpress - Get images used in, but not attached to page? -


i want of images used in page. code i'm using:

function get_page_images($id) {     $photos = get_children( array(         'post_parent' => $id,         'post_status' => 'inherit',         'post_type' => 'attachment',         'post_mime_type' => 'image',         'order' => 'asc',         'orderby' => 'menu_order id') );      $results = array();      if ($photos) {         foreach ($photos $photo) {             // correct image html selected size             $results[] = wp_get_attachment_image($photo->id, $size);         }     }      return $results; } 

this gets images uploaded page, if have reused image uploaded different page/post, aren't retrieved (as attached post uploaded to, not posts reused in). know way all images used in page/post?

use built-in php dom parser grab images located in content. code untested, should started in right direction:

<?php while(have_posts()) : the_post();     $dom = new domdocument();     $dom->loadhtml(get_the_content());     $images = $dom->getelementsbytagname('img');     foreach($images $img){         $src = $img->getattribute('src');         printf('<img src="%s" />', $src);     } endwhile; ?> 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -