diff --git a/src/components/ImageDisplay/ImageDisplay.jsx b/src/components/ImageDisplay/ImageDisplay.jsx index 826628e..c7e12e2 100644 --- a/src/components/ImageDisplay/ImageDisplay.jsx +++ b/src/components/ImageDisplay/ImageDisplay.jsx @@ -14,7 +14,7 @@ import wordColor from '../../assets/images/section7Image.svg'; import wordMonochrome01 from '../../assets/images/section8FirstImage.svg'; import wordMonochrome02 from '../../assets/images/section8SecondImage.svg'; export default function ImageDisplay(props) { - const { image, image2, zipDownload } = props; + const { image, image2, zipDownload, imageName } = props; const images = [ { name: 'fullLogo.svg', url: fullLogo }, @@ -68,18 +68,23 @@ export default function ImageDisplay(props) { }); }; - // Function to download an image - const downloadImage = (src, filename) => { - // Create a temporary anchor element + const downloadImage = async (src, filename) => { + const response = await fetch(src); + const blob = await response.blob(); + const url = URL.createObjectURL(blob); + const link = document.createElement('a'); - link.href = src; + link.href = url; link.download = filename || 'downloaded-image'; - - // Append to the body, click, and remove + document.body.appendChild(link); link.click(); document.body.removeChild(link); + + // Clean up the object URL + URL.revokeObjectURL(url); }; + // Function to generate filename const generateFilename = (src) => { @@ -95,7 +100,7 @@ export default function ImageDisplay(props) {