Made the regexp for image alt extraction more generic

This commit is contained in:
pezcurrel 2024-10-27 09:39:45 +01:00
parent 924faff128
commit a944c076d7

View file

@ -358,7 +358,7 @@ foreach ($feed->channel->item as $item) {
$hash=$item->title.$item->pubDate;
if (isset($item->enclosure[0]['url']) && isset($item->enclosure[0]['type']) && isset($item->enclosure[0]['length'])) {
$file=['url'=>$item->enclosure[0]['url']->__toString(), 'type'=>$item->enclosure[0]['type']->__toString(), 'length'=>$item->enclosure[0]['length']->__toString()];
if (preg_match('#<img alt="([^"]+)"#',$item->description->__toString(),$matches)===1) $imgalt=trim($matches[1]);
if (preg_match('#<img [^>]*alt="([^"]+)"#',$item->description->__toString(),$matches)===1) $imgalt=trim($matches[1]);
$hash.=$item->enclosure[0]['url'].$item->enclosure[0]['type'].$item->enclosure[0]['length'].$imgalt;
}
if ($imgalt=='') $imgalt='Flyer dellevento';