Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Bootstrap 4 gallery
- * Base galeria padrĂ£o / Default gallery: https://core.trac.wordpress.org/browser/trunk/src/wp-includes/media.php#L1677
- */
- add_filter( 'post_gallery', 'wpmidia_bootstrap_gallery', 10, 2);
- function wpmidia_bootstrap_gallery( $output = '', $atts ) {
- if (strlen($atts['columns']) < 1) $columns = 3;
- else $columns = $atts['columns'];
- $images = explode(',', $atts['ids']);
- if ( $columns < 1 || $columns > 12 ) $columns == 3;
- $col_class = 'col-lg-' . 12/$columns;
- $output = '<div class="row text-center text-lg-left gallery">';
- $i = 0;
- foreach ( $images as $key => $value ) {
- $image_attributes = wp_get_attachment_image_src( $value, 'full'); //"Full" para o responsivo :)
- $output .= '
- <div class="'.$col_class.'">
- <a data-gallery="gallery" href="'.esc_url($image_attributes[0]).'" class="d-block mb-4 h-100">
- <img src="'.esc_url($image_attributes[0]).'" alt="" class="img-fluid img-thumbnail">
- </a>
- </div>';
- $i++;
- }
- $output .= '</div>';
- return $output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement