WordPress: aggiungere automaticamente un effetto lightbox a tutte le gallerie

In WordPress è relativamente semplice aggiungere un effetto lightbox a tutte le gallerie in modo automatico.

La soluzione è la seguente:


if( $( ".gallery" ).length ) {
  $( ".gallery" ).each(function() {
      var $links = $( this ).find( "a" );
      $links.each(function() {
          var $link = $( this );
          var href = this.href;
          // Punta ad un'immagine?
          if( /(\.jpe?g|\.png|\.bmp|\.gif)$/.test( href ) ) {
              $link.plugin();
          }
      });
  });
}

Sostituite .plugin() con il plugin che state usando.

Torna su