Salve, ho questa funzione e vorrei sapere come poterla modificare in modo che riconosca se l'immagine proviene da www.miosito.it oppure da un altro.
Potete anche indicarmi se la soluzione da me apportata è corretta?
Se l'immagine provenisse da un altro sito allora deve eseguire un codice diverso
Codice PHP:
function catch_first_image($text) {
$first_img = '';
$text = str_replace("\\","",$text);
$output = preg_match_all('/<img.+src=\"([^\\'"]+)\".*>/i', $text, $matches);
if(isset($matches[1][0]) && strstr($matches[0][1], 'www.miosito.it')) {
//... eseguo del codice
$first_img = 'url-immagine';
} else {
$first_img = isset($matches[1][0]) ? $matches[1][0] : "";
}
if(!empty($first_img)){ //Defines a default image
return IMAGES_URL.'articles/news/'.basename($first_img);
} else {
return false;
}
}
1000 Grazie