Support » Theme: Spun » Lightbox-ing or Colorbox-ing the galleries

  • Resolved djalouk


    To make this theme a bit more perfect, I’m trying to add a “lightbox” (or a colorbox) plugin to the galleries post.

    Did you find a way to easily doing it ?

    Thanks for your help.

Viewing 9 replies - 1 through 9 (of 9 total)
  • I tried “Lightbox Plus ColorBox 2.6”.

    It works on images included in default format posts and on native WP galleries (but thumbnails are square-shaped).

    I didn’t manage to make it work on post gallery format. Any idea ?

    Thanks for your help.

    Ok, in the post gallery format, the attachment page is used in the thumbnails instead of the image URL.

    I’m not a WP expert, but it seems I need to hack some code to link the image URL so that the lightbox settings will apply (like in the post default format).

    I guess I found the code used for the post gallery format, in image.php :

    									 * Grab the IDs of all the image attachments in a gallery so we can get the URL of the next adjacent image in a gallery,
    									 * or the first image (if we're looking at the last image in a gallery), or, in a gallery of one, just the link to that image file
    									$attachments = array_values( get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) );
    									foreach ( $attachments as $k => $attachment ) {
    										if ( $attachment->ID == $post->ID )
    									// If there is more than 1 attachment in a gallery
    									if ( count( $attachments ) > 1 ) {
    										if ( isset( $attachments[ $k ] ) )
    											// get the URL of the next image attachment
    											$next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
    											// or get the URL of the first image attachment
    											$next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );
    									} else {
    										// or, if there's only 1 image, get the URL of the image
    										$next_attachment_url = wp_get_attachment_url();
    								<a href="<?php echo $next_attachment_url; ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php
    									$attachment_size = apply_filters( 'spun_attachment_size', array( 1200, 1200 ) ); // Filterable image size.
    									echo wp_get_attachment_image( $post->ID, $attachment_size );

    If the href attribute directly points to the image URL instead of the attachment ID, it will work. But I have no idea how to modify the code ?

    Can somebody advice on this ?


    My previous statement is wrong.

    I need to change the way the link is generated in thumbnails in the post gallery format.

    Does anybody have an idea how to do this ?


    In content-gallery.php :

    if I add link=”file” like this :

    <?php echo do_shortcode( '[gallery link="file" type="rectangular" captiontag="0" columns="4"]' ); ?>

    The images are displayed in a modal panel, but that’s it, no CSS is applied and no navigation buttons are available to browse the gallery…

    I guess I’m not the only one who’s trying to do this ?

    I’ve find a solution.

    I used a native WP gallery : Media > create a gallery.

    I add link=”file” to the generated gallery.

    I add this in my child theme to make the thumbnails looks like the spun post gallery format :

    .site-content .gallery a img {
      border-radius : 180px;

    And now, I’ve beautiful lightbox galleries.

    Hope this thread can help.

    Any chance of a link to your site so we can see what you mean?

    I’m working on a local copy…

    Hi there djalouk, did you do a local copy at all? thanks

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Lightbox-ing or Colorbox-ing the galleries’ is closed to new replies.