foreach ($aentries as $aentry) {
 
-                                                               if (!in_array($aentry->getAttribute("content"), $urls)) {
+                                                               $url = str_replace("?fb", "", $aentry->getAttribute("content"));
+
+                                                               if (!in_array($url, $urls)) {
                                                                        $img = $doc->createElement('img');
-                                                                       $img->setAttribute("src", str_replace("?fb", "", $aentry->getAttribute("content")));
+                                                                       $img->setAttribute("src", $url);
                                                                        $entry->parentNode->insertBefore($doc->createElement('br'), $entry);
 
                                                                        $br = $doc->createElement('br');
                                                                        $entry->parentNode->insertBefore($img, $entry);
                                                                        $entry->parentNode->insertBefore($br, $entry);
 
-                                                                       array_push($urls, $aentry->getAttribute("content"));
+                                                                       array_push($urls, $url);
 
                                                                        $found = true;
                                                                }