Opening a gallery image in a new tab

Hi!! I wanted to simply make it possible when clicking on an image in a gallery, for that image to be opened in full size (not cropped) in a new tab.

Right now, clicking on an image leads to a new tab of the same page, not of the image itself.

This is the current code:

<div class="storypage__gallery">
        <?php $images = $page->pictures()->toFiles(); 
         foreach($images as $picture): ?>
        <div class="storypage__gallery__item">
        <img src="<?=$picture->thumb(array('width' => 200, 'height' => 200, 'crop'=>true))->url()?>" onclick="gallery('<?=$page->url() ."/" .$picture->image() ?>')"/>
        
        </div>
   <?php endforeach ?>

$picture->image() doesn’t make sense. Use $picture->url(), without the page url. I think wrapping the image in an a tag would probably be more accessible than onclick?

1 Like

Ahh thanks so much! Works perfectly now :smiley: