WordPress.org

Ready to get started?Download WordPress

Forums

Spun
[resolved] Lightbox-ing or Colorbox-ing the galleries (10 posts)

  1. djalouk
    Member
    Posted 1 year ago #

    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.

  2. djalouk
    Member
    Posted 1 year ago #

    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.

  3. djalouk
    Member
    Posted 1 year ago #

    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).

  4. djalouk
    Member
    Posted 1 year ago #

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

    <?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 )
    											break;
    									}
    									$k++;
    									// 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 );
    										else
    											// 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 );
    								?></a>

    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 ?

    Thanks.

  5. djalouk
    Member
    Posted 1 year ago #

    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 ?

    Thanks.

  6. djalouk
    Member
    Posted 1 year ago #

    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 ?

  7. djalouk
    Member
    Posted 1 year ago #

    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.

  8. contagous
    Member
    Posted 1 year ago #

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

  9. djalouk
    Member
    Posted 1 year ago #

    I'm working on a local copy...

  10. LEVI44
    Member
    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic

Tags

No tags yet.