Skip to content

Commit

Permalink
fix: fixed image url in Photogallery listing popup (#383)
Browse files Browse the repository at this point in the history
* fix: fixed image url in Photogallery listing popup

* chore: updated checkUrlImage condition
  • Loading branch information
SaraBianchi authored Oct 31, 2023
1 parent a30064e commit b8d2e20
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import {
} from 'design-comuni-plone-theme/components/ItaliaTheme';
import React, { useRef, useState } from 'react';
import { defineMessages, useIntl } from 'react-intl';

import DefaultImageSVG from '@plone/volto/components/manage/Blocks/Listing/default-image.svg';
import { GalleryPreview } from 'design-comuni-plone-theme/components/ItaliaTheme';
import { Icon } from 'design-comuni-plone-theme/components/ItaliaTheme';
import PropTypes from 'prop-types';
Expand Down Expand Up @@ -139,12 +137,14 @@ const PhotogalleryTemplate = ({

const getCaption = (item) => item.description ?? item.rights ?? null;

const figure = (image, item) => (
<figure className="img-wrapper">
{image ? <>{image}</> : <img src={DefaultImageSVG} alt="" />}
{getCaption(item) && <figcaption>{getCaption(item)}</figcaption>}
</figure>
);
const figure = (image, item) => {
return (
<figure className="img-wrapper">
{image}
{getCaption(item) && <figcaption>{getCaption(item)}</figcaption>}
</figure>
);
};

return (
<div className="photogallery">
Expand Down
11 changes: 6 additions & 5 deletions src/components/ItaliaTheme/GalleryPreview/GalleryPreview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { defineMessages, useIntl } from 'react-intl';
import { flattenToAppURL } from '@plone/volto/helpers';

import PropTypes from 'prop-types';

import { Modal, ModalBody, Button, ModalHeader } from 'design-react-kit';
import { Icon } from 'design-comuni-plone-theme/components/ItaliaTheme';
import DefaultImageSVG from '@plone/volto/components/manage/Blocks/Listing/default-image.svg';
Expand Down Expand Up @@ -34,6 +33,10 @@ const GalleryPreview = ({ id, viewIndex, setViewIndex, items }) => {
const intl = useIntl();
const [modalIsOpen, setModalIsOpen] = useState(false);

const checkUrlImage =
items[viewIndex]?.image?.scales?.larger?.download ||
items[viewIndex]?.image_scales?.image[0]?.scales?.larger?.download;

const closeModal = () => {
setViewIndex(null);
};
Expand Down Expand Up @@ -92,11 +95,9 @@ const GalleryPreview = ({ id, viewIndex, setViewIndex, items }) => {
</Button>
)}
<div className="image">
{items[viewIndex].image ? (
{checkUrlImage ? (
<img
src={flattenToAppURL(
items[viewIndex].image.scales.larger.download,
)}
src={flattenToAppURL(checkUrlImage)}
loading="lazy"
alt={items[viewIndex].title}
/>
Expand Down

0 comments on commit b8d2e20

Please sign in to comment.