paquettg/php-html-parser

need insert noscript tag after img tag

gebaiwan opened this issue · 1 comments

what i do:

$imgs = $html->find('img');
foreach($imgs as $img){
      $img->insertAfter(new Dom\Node\TextNode('<noscript><img src="'.$img_src.'" alt="'.$img_alt.'"></noscript>'), $img->id());
}
unset($imgs);
$formatted = $html->outHtml;

but isn't work.
thanks for your help!

$imgs = $html->find('img');
foreach($imgs as $img){
    $img->getParent()->insertAfter(new Dom\Node\TextNode('<noscript><img src="'.$img_src.'" alt="'.$img_alt.'"></noscript>'), $img->id());
}
unset($imgs);
$formatted = $html->outHtml;

it worked.
thanks.