• Resolved thebettertwin

    (@thebettertwin)


    Hi i decided to try and add the nivoslider to display the gallery images on the front page. For some reason tho it adds an extra blank slide.
    I think it may be down to the line break the gallery adds. if so how do i get rid of this?
    This is what i call:
    [gallery size="full" itemtag="div" icontag="span" captiontag="p" columns="0"]
    This is the HTML:

    <div class='gallery'><div class='gallery-item'>
    			<span class='gallery-icon'>
    
    					<a href="https://localhost/wordpress/wp-content/uploads/2010/09/slide1.jpg" title="slide1" rel="gallery-4">
    
    					<img src="https://localhost/wordpress/wp-content/uploads/2010/09/slide1.jpg" alt="slide1" />
    
    					</a>	
    
    			</span></div><div class='gallery-item'>
    			<span class='gallery-icon'>
    
    					<a href="https://localhost/wordpress/wp-content/uploads/2010/09/slide2.jpg" title="slide2" rel="gallery-4">
    
    					<img src="https://localhost/wordpress/wp-content/uploads/2010/09/slide2.jpg" alt="slide2" />
    
    					</a>	
    
    			</span></div><div class='gallery-item'>
    			<span class='gallery-icon'>
    
    					<a href="https://localhost/wordpress/wp-content/uploads/2010/09/slide3.jpg" title="slide3" rel="gallery-4">
    
    					<img src="https://localhost/wordpress/wp-content/uploads/2010/09/slide3.jpg" alt="slide3" />
    
    					</a>	
    
    			</span></div>
    			<br style='clear: both;' />
    		</div>

    And the relevant nivo slider options:

    jQuery(document).ready(function($){
    
    $(window).load(function() {
    	$('.gallery').nivoSlider({
    		effect:'random', //Specify sets like: 'fold,fade,sliceDown'
    		slices:15,
    		animSpeed:1000, //Slide transition speed
    		pauseTime:3000,
    		startSlide:0, //Set starting Slide (0 index)
    		directionNav:false, //Next & Prev
    		directionNavHide:true, //Only show on hover
    		controlNav:true, //1,2,3...
    		controlNavThumbs:false, //Use thumbnails for Control Nav
          controlNavThumbsFromRel:false, //Use image rel for thumbs
    		controlNavThumbsSearch: '.jpg', //Replace this with...
    		controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
    		keyboardNav:true, //Use left & right arrows
    		pauseOnHover:true, //Stop animation while hovering
    		manualAdvance:false, //Force manual transitions
    		captionOpacity:0.8, //Universal caption opacity
    		beforeChange: function(){},
    		afterChange: function(){},
    		slideshowEnd: function(){} //Triggers after all slides have been shown
    	});
    });
    });

    Anyway to get rid of the blank slide?
    Thanks in advance

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter thebettertwin

    (@thebettertwin)

    bump

    Thread Starter thebettertwin

    (@thebettertwin)

    Figured this one out myself so if anyone else comes across the same problem i thought i should post a solution.
    I found this code in wp-includes/media.php and removed the <br style=”clear:both” /> from the bottom of it after pasting it into functions and adding a gallery overide:

    /* gallery override */
    remove_shortcode('gallery');
    add_shortcode('gallery', 'my_gallery_shortcode' );
    
    function my_gallery_shortcode($attr) {
    global $post, $wp_locale;
    
      static $instance = 0;
      $instance++;
    
      // Allow plugins/themes to override the default gallery template.
      $output = apply_filters('post_gallery', '', $attr);
      if ( $output != '' )
        return $output;
    
      // We're trusting author input, so let's at least make sure it looks like a valid orderby statement
      if ( isset( $attr['orderby'] ) ) {
        $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
        if ( !$attr['orderby'] )
          unset( $attr['orderby'] );
      }
    
      extract(shortcode_atts(array(
        'order'      => 'ASC',
        'orderby'    => 'menu_order ID',
        'id'         => $post->ID,
        'itemtag'    => 'dl',
        'icontag'    => 'dt',
        'captiontag' => 'dd',
        'columns'    => 3,
        'size'       => 'thumbnail',
        'include'    => '',
        'exclude'    => ''
      ), $attr));
    
      $id = intval($id);
      if ( 'RAND' == $order )
        $orderby = 'none';
    
      if ( !empty($include) ) {
        $include = preg_replace( '/[^0-9,]+/', '', $include );
        $_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
    
        $attachments = array();
        foreach ( $_attachments as $key => $val ) {
          $attachments[$val->ID] = $_attachments[$key];
        }
      } elseif ( !empty($exclude) ) {
        $exclude = preg_replace( '/[^0-9,]+/', '', $exclude );
        $attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
      } else {
        $attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
      }
    
      if ( empty($attachments) )
        return '';
    
      if ( is_feed() ) {
        $output = "\n";
        foreach ( $attachments as $att_id => $attachment )
          $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
        return $output;
      }
    
      $itemtag = tag_escape($itemtag);
      $captiontag = tag_escape($captiontag);
      $columns = intval($columns);
      $itemwidth = $columns > 0 ? floor(100/$columns) : 100;
      $float = is_rtl() ? 'right' : 'left';
    
      $selector = "gallery-{$instance}";
    
      $output = apply_filters('gallery_style', "
        <style type='text/css'>
          #{$selector} {
            margin: auto;
          }
          #{$selector} .gallery-item {
            float: {$float};
            margin-top: 10px;
            text-align: center;
            width: {$itemwidth}%;     }
          #{$selector} img {
            border: 2px solid #cfcfcf;
          }
          #{$selector} .gallery-caption {
            margin-left: 0;
          }
        </style>
        <!-- see gallery_shortcode() in wp-includes/media.php -->
        <div id='$selector' class='gallery galleryid-{$id}'>");
    
      $i = 0;
      foreach ( $attachments as $id => $attachment ) {
        $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
    
        $output .= "<{$itemtag} class='gallery-item'>";
        $output .= "
          <{$icontag} class='gallery-icon'>
            $link
          </{$icontag}>";
        if ( $captiontag && trim($attachment->post_excerpt) ) {
          $output .= "
            <{$captiontag} class='gallery-caption'>
            " . wptexturize($attachment->post_excerpt) . "
            </{$captiontag}>";
        }
        $output .= "</{$itemtag}>";
        if ( $columns > 0 && ++$i % $columns == 0 )
          $output .= '';
      }
    
      $output .= "
    
        </div>\n";
    
      return $output;
    }
    /* gallery override */

    I too had the same problem.

    But mine was due to Disqus plug-in adding extra information to the header. I disabled it and it worked.

    Make sure no plugin adds extra information before the plug-in ends.

    I have the same problem with a new theme that uses nivoslider to display featured blog posts. Turning off the Disqus plugin resolvs the issue with the extra slide however, I want to keep using Disqus. Is there anyone who can suggest a solution in order to keep Disqus enabled?

    Thanks a lot!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Nivo image slider adds an extra blank slide in wordpress’ is closed to new replies.