Ciao ragazzi,
uso lo script di seguito per estrarre immagini dagli articoli presenti in WP.
Vorrei impostare un controllo sulla dimensione delle immagini.
Ad esempio, se un immagine è uguale o superiore a 100pxX100px va considerata e quindi estratta altrimenti mostra l'immagine di default.
Me la date una mano?
Codice PHP:
function catch_image_url() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_img = $matches [1] [0];
if(empty($first_img)){
$first_img = "/images/default.jpg";
}
return $first_img;
}