View Snippet #202

    /*
 * Add itemprop='image' to an image
 */
function cb_add_itemprop_image($image) {
    $dom = new DOMDocument();
    $dom->loadHTML($image);
    //echo "";
    foreach ($dom->getElementsByTagName('img') as $item) {
  $item->setAttribute('itemprop', 'image');
  $return=$dom->saveHTML($item);
  $return2=addslashes($return);
  //echo "";
  return $return;
    }
}