app/basis.php
/**
 *
 * Format the WordPress Gallery and add Bootstrap Grid support
 *
 */
Format the WordPress Gallery and add Bootstrap Grid support
Format the WordPress Gallery and add Bootstrap Grid support
function basis_gallery( $output = '', $atts, $instance ) {
	if ( empty( $atts ) ) {
		return $output;
	}
	$columns = $atts['columns'];
	if ( strlen( $atts['columns'] ) < 1 || ! isset( $atts['columns'] ) || $columns > 12 ) {
		$columns = 3;
	}
	$col_class = 'col-sm-' . floor( 12 / $columns ); 
	$return = '<div class="row gallery">';
	$image_ids = explode( ',', $atts['ids'] );
	foreach ( $image_ids as $key => $image_id ) {
		$image_url = get_image( (int) $image_id, $atts['size'] );
		$caption   = get_post( (int) $image_id );
		$return    .= '
            <div class="' . $col_class . '">
                <div class="gallery-image-wrap">
                    <a data-featherlight="' . $image_url . '" data-gallery="gallery" href="#">
                        <img src="' . $image_url . '" alt="" class="img-fluid">
                        <p class="wp-caption caption">' . $caption->post_excerpt . '</p>
                    </a>
                </div>
            </div>';
	}
	$return .= '</div>';
	return $return;
}
function basis_gallery ( $ output = '' , $ atts , $ instance ) { if ( empty ( $ atts ) ) { return $ output ; } $ columns = $ atts [ 'columns' ] ; if ( strlen ( $ atts [ 'columns' ] ) < 1 || ! isset ( $ atts [ 'columns' ] ) || $ columns > 12 ) { $ columns = 3 ; } $ col_class = 'col-sm-' . floor ( 12 / $ columns ) ; $ return = '<div class="row gallery">' ; $ image_ids = explode ( ',' , $ atts [ 'ids' ] ) ; foreach ( $ image_ids as $ key => $ image_id ) { $ image_url = get_image ( ( int ) $ image_id , $ atts [ 'size' ] ) ; $ caption = get_post ( ( int ) $ image_id ) ; $ return .= '
            <div class="' . $ col_class . '">
                <div class="gallery-image-wrap">
                    <a data-featherlight="' . $ image_url . '" data-gallery="gallery" href="#">
                        <img src="' . $ image_url . '" alt="" class="img-fluid">
                        <p class="wp-caption caption">' . $ caption -> post_excerpt . '</p>
                    </a>
                </div>
            </div>' ; } $ return .= '</div>' ; return $ return ; }
Format the WordPress Gallery and add Bootstrap Grid support
Format the WordPress Gallery and add Bootstrap Grid support
// floor(): not a great way to handle 5 columns, but good enough for now