Измените строку на:
if (isset($imagelinked['src'][$indexlinked]) && $imagesrc == $imagelinked['src'][$indexlinked]) {
... и ошибка должна исчезнуть.
РЕДАКТИРОВАТЬ Вот отредактированная версия функции, в которой исключена эта ошибка, удалена пара бессмысленных переменных, объединена пара строк и добавлен отсутствующий {
.
function crawlImage ($url) {
$domain = $this->getDomain($url);
//echo $domain,'<br>';
$dom = new DOMDocument();
@$dom->loadHTML($this->getContent($url));
$xdoc = new DOMXPath($dom);
// Read the images that is between <a> tag
$atags = $xdoc->evaluate("//a"); // Read all <a> tags
for ($index = 0, $i = 0; $i < $atags->length; $i++) {
$atag = $atags->item($i); // Select an <a> tag
$imagetags = $atag->getElementsByTagName("img");//get img tag
$imagetag = $imagetags->item(0);
if (sizeof($imagetag) > 0) { // If <img> tag exists
$imagelinked['src'][$index] = $imagetag->getAttribute('src'); // Save image src
$imagelinked['link'][$index] = $atag->getAttribute('href'); // Save image link
$index++;
}
}
// Read all images between <img> tag
$imagetags = $xdoc->evaluate("//img"); //Read all img tags
for ($indexlinked = 0, $i = 0; $i < $imagetags->length; $i++) {
$imagetag = $imagetags->item($i);
$imagesrc = $imagetag->getAttribute('src');
$image['link'][$i] = NULL;
if (isset($imagelinked['src'][$indexlinked]) && $imagesrc == $imagelinked['src'][$indexlinked]) {
$image['link'][$i] = $this->convertLink($domain,$url,$imagelinked['link'][$indexlinked]);
$indexlinked++;
}
$image['src'][$i] = $this->convertLink($domain,$url,$imagesrc);
}
return $image;
}