Skip to content

Commit

Permalink
✨ Clicking an image opens it in a new tab (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
mglyrasis authored Jun 21, 2024
1 parent f76473f commit 12f0cef
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/components/detail/ImageGallery.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global window */

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { defineMessages, injectIntl } from 'react-intl';
Expand Down Expand Up @@ -45,6 +47,13 @@ const getInstitutionIds = () => {
return (institutionsConfig ? Object.keys(institutionsConfig) : []);
};

const handleImageClick = (event) => {
const imageUrl = event.target.src;
if (typeof window !== 'undefined') {
window.open(imageUrl, '_blank');
}
};

class ImageGallery extends Component {
componentDidMount() {
this.findMedia();
Expand Down Expand Up @@ -135,6 +144,7 @@ class ImageGallery extends Component {
<Gallery
disableArrowKeys
items={items}
onClick={handleImageClick}
showFullscreenButton={false}
showPlayButton={false}
showThumbnails={items.length > 1}
Expand Down

0 comments on commit 12f0cef

Please sign in to comment.