Lightbox Group for custom hook
-
I have this custom hook for WordPress Galleries:
function custom_gallery_output( $output, $atts, $instance ) {
global $post;// Get the gallery image IDs if ( isset( $atts['ids'] ) ) { $ids = explode( ',', $atts['ids'] ); } else { $ids = []; } if ( empty( $ids ) ) { return $output; } $gallery_id = 'gallery-' . $post->ID; $output = '<div class="custom-gallery">'; foreach ( $ids as $id ) { $image_url = wp_get_attachment_image_url( $id, 'full' ); $output .= '<figure class="gallery-item">'; $output .= '<div class="gallery-icon landscape">'; $output .= '<a href="' . esc_url( $image_url ) . '" class="gallery" data-lightbox="gallery" style="display:block; background-image:url(' . esc_url( $image_url ) . '); background-size:cover; background-position:center; width:100%; height:300px;"></a>'; $output .= '</div></figure>'; } $output .= '</div>'; return $output;
}
add_filter( ‘post_gallery’, ‘custom_gallery_output’, 10, 3 );This works, except it only shows one image, I am trying to create a set via data-lightbox=”gallery” but that did not work. It opens the image I click on in lightbox, but I have to close it and open the next image, Dont know why the arrows dont appear.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- You must be logged in to reply to this topic.