Quali potrebbero essere le cause per cui un'immagine in evidenza non viene visualizzata?
Sto scrivendo un child theme per il tema editr e l'immagine in evidenza non viene visualizzata per un nuovo articolo. Le immagini in evidenza vengono visualizzate correttamente per i contenuti demo. Per il nuovo articolo, viene renderizzato il seguente markup:
<div class="featured" data-img_bg="">
<img src="" alt="" style="display: block;">
</div>
La sezione rilevante del template è:
<?php if ( ( $show_thumb || $show_thumb == '' ) && has_post_thumbnail() ) { ?>
<div class="featured" data-img_bg="<?php echo $image; ?>">
<img src="<?php echo $image; ?>" alt="">
</div>
<?php } ?>
Questo avviene su una VM Vagrant locale che esegue Ubuntu 14.04, nginx, PHP 5.6.
Ho controllato le opzioni 'Mostra miniatura in evidenza?' e 'Articolo in evidenza?' nell'editor dell'articolo. In cima al template, trovo che il valore di $image è vuoto:
<?php
$show_thumb = get_post_meta(get_the_ID(), 'aq_show_thumbnail', TRUE);
$thumb = wp_get_attachment_url( get_post_thumbnail_id(), 'full');
echo 'thumb value is set to'.$thumb;
$image = aq_resize( $thumb, 1000, 400, true );
echo 'image value is set to'.$image;
?>
AGGIORNAMENTO
Analizzando con xdebug si vede che la funzione aq_resize fallisce nel seguente codice:
else {
$editor = wp_get_image_editor($img_path);
if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) )
return false;
$resized_file = $editor->save();
if(!is_wp_error($resized_file)) {
$resized_rel_path = str_replace( $upload_dir, '', $resized_file['path']);
$img_url = $upload_url . $resized_rel_path;
} else {
return false;
}
}
$editor
è impostato su 'Nessun editor potrebbe essere selezionato.'

L'estensione PHP GD non era installata sulla mia macchina di sviluppo. Installare php5-gd ha risolto il problema - sudo apt-get install php5-gd
Analizzando il codice con xdebug ho scoperto che la funzione aq_resize
del tema falliva nel seguente codice:
else {
$editor = wp_get_image_editor($img_path);
if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) )
return false;
$resized_file = $editor->save();
if(!is_wp_error($resized_file)) {
$resized_rel_path = str_replace( $upload_dir, '', $resized_file['path']);
$img_url = $upload_url . $resized_rel_path;
} else {
return false;
}
}
$editor
era impostato su 'Nessun editor potrebbe essere selezionato.'

L'output HTML viene visualizzato nella pagina? Se no, allora il problema è quasi sicuramente nel tuo statement if. Dovrebbe essere:
if ( ( $show_thumb || $show_thumb !== '' ) && has_post_thumbnail() )
invece di:
if ( ( $show_thumb || $show_thumb == '' ) && has_post_thumbnail() )
