title: How to limit or define specific images for each gallery using a class
body: <p>I have created numerous picture galleries on the same page. If I click on one gallery picture, fancybox v3.5.7 opens and you are able to click through not just this gallery but all pictures in the WP Media library.</p>
  <p>I'd like to limit the view to the specific gallery.</p>
  <p>How do I adjust the jQuery code to achieve this?</p>
  <p>I know how to give each gallery a class, but where do I put this jQuery code?</p>
  <p>With this jQuery line I activate fancybox-3 for WordPress:</p>
  <pre><code>$( &quot;a[href$='.jpg'], a[href$='.jpeg'], a[href$='.png'], a[href$='.gif']&quot; ) . attr( 'data-fancybox', 'gallery' ) . fancybox({
      
        buttons: [
          &quot;zoom&quot;,
          //&quot;share&quot;,
          //&quot;slideShow&quot;,
          &quot;fullScreen&quot;,
          //&quot;download&quot;,
          //&quot;thumbs&quot;, // blendet Buttons für Thumbnails ein
          &quot;close&quot;
          ],
  
      (and so on)
  
      });
  </code></pre>