'ASC',
'orderby' => 'menu_order ID',
'id' => $post ? $post->ID : 0,
'itemtag' => 'dl',
'icontag' => 'dt',
'captiontag' => 'dd',
'columns' => 3,
'size' => 'thumbnail',
'include' => '',
'exclude' => '',
'link' => ''
), $attr, 'gallery'));
$id = intval($id); // questo rappresenta l'ID della pagina/post in cui è stato inserito lo shortcode gallery
// andiamo a creare un'array che contenga tutte le immagini selezionate dall'utente per la galleria
if ( !empty($include) ) {
$_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
$attachments = array();
foreach ( $_attachments as $key => $val ) {
$attachments[$val->ID] = $_attachments[$key];
}
} elseif ( !empty($exclude) ) {
$attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
} else {
// se non diversamente specificato prendo tutte le immagini caricate nella pagina/post
$attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
}
$output = '
'; // il div contenitore con le varie configurazioni inline per il plugin jQuery Cycle
$output .= '
'; // i 2 div che useremo per mostrare le info aggiuntive sulle immagini
$i = 0;
foreach ( $attachments as $id => $attachment ) {
$image_data = wp_get_attachment_image_src( $id, 'slideshow-custom-dimension'); // ritorna un array contenente gli attributi "url", "width" e "height" dell'immagine richiesta (della nostra dimensione personalizzata)
$image_meta = wp_get_attachment_metadata($id); // dovessero servire i metadati dell'immagine, a noi non serviranno
$output .= '

';
}
$output .= '
« | »
'; // aggiungo i comandi di navigazione per scorrere le immagini
// carichiamo css e javascript aggiuntivi
wp_enqueue_style('slideshow-css', get_template_directory_uri() . '/slideshow/demo-slideshow.css', array(), '1.0');
//wp_enqueue_script('jquery-lib', get_template_directory_uri() . '/slideshow/jquery.js', array(), '1.0', true); // caricare solo se il vostro tema non usa jquery
wp_enqueue_script('slideshow-js-cycle', get_template_directory_uri() . '/slideshow/cycle.js', array(), '1.0', true); // assicurarsi che il vostro tema chiami wp_footer()
wp_enqueue_script('slideshow-js-cycle-plugin', get_template_directory_uri() . '/slideshow/caption_plugin.js', array(), '1.0', true); // assicurarsi che il vostro tema chiami wp_footer()
return $output;
}
// aggiunge una nuova dimensione personalizzata per le immagini del nostro slideshow
add_image_size('slideshow-custom-dimension', 600, 400, true);