$attachment ) $output .= wp_get_attachment_link( $att_id, $size, true ) . "\n"; return $output; } $inside_cube = isset( $GLOBALS['vamtam_inside_cube'] ) && $GLOBALS['vamtam_inside_cube']; if ( $inside_cube ) { $output .= '
'; $output .= '
'; VamtamOverrides::unlimited_image_sizes(); // check for matching VamtamOverrides::limit_image_sizes(); below } else { if ( VamtamTemplates::early_cube_load() ) { wp_enqueue_script( 'cubeportfolio' ); } wp_enqueue_style( 'cubeportfolio' ); $slider_options = array( 'layoutMode' => 'slider', 'drag' => true, 'auto' => false, 'autoTimeout' => 5000, 'autoPauseOnHover' => true, 'showNavigation' => true, 'showPagination' => true, 'rewindNav' => true, 'gridAdjustment' => 'responsive', 'mediaQueries' => array( array( 'width' => 1, 'cols' => 1, ), ), 'gapHorizontal' => 0, 'gapVertical' => 0, 'caption' => '', 'displayType' => 'default', ); $output .= '
'; } foreach ( $attachments as $id => $attachment ) { $image = wp_get_attachment_image( $id, $attr['size'] ); if ( ! empty( $image ) ) { if ( $inside_cube ) { $output .= '
'; $output .= ''; $output .= $image; $output .= ''; $output .= '
'; } else { $output .= '
'; $output .= $image; $output .= '
'; } } } if ( $inside_cube ) { VamtamOverrides::limit_image_sizes(); $output .= '
'; } else { $output .= '
'; } return $output; } public static function gallery_lightbox( $attr ) { // Allow plugins/child themes to override the default gallery template. $output = apply_filters( 'vamtam_post_gallery_lightbox', '', $attr ); if ( '' != $output ) { return $output; } $attachments = self::get_attachments( $attr ); if ( empty( $attachments ) ) return ''; if ( is_feed() ) { return ''; } foreach ( $attachments as $id => $attachment ) { $image_src = wp_get_attachment_image_src( $id, 'full' ); if ( ! empty( $image_src ) && ! empty( $image_src[0] ) ) { $output .= ''; } } return $output; } public static function get_attachments( $attr ) { extract( self::process_atts( $attr ) ); $id = intval( $id ); if ( 'RAND' == $order ) { $orderby = 'none'; } 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 { $attachments = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby, ) ); } return $attachments; } public static function process_atts( $attr ) { $post = get_post(); if ( ! empty( $attr['ids'] ) ) { // 'ids' is explicitly ordered, unless you specify otherwise. if ( empty( $attr['orderby'] ) ) { $attr['orderby'] = 'post__in'; } $attr['include'] = $attr['ids']; } // We're trusting author input, so let's at least make sure it looks like a valid orderby statement if ( isset( $attr['orderby'] ) ) { $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] ); if ( ! $attr['orderby'] ) { unset( $attr['orderby'] ); } } return shortcode_atts(array( 'order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => '', 'pausetime' => 3000, 'direction' => 'none', 'where' => 'single', ), $attr, 'gallery'); } } new Vamtam_Gallery;