Shopify themes, liquid, logos, and UX
I've got an image of a map on a general FAQ page (not a product image etc).
I need the user to be able to click on the image to see it full size in a pop-up that can then be closed to go back to the page.
Solved! Go to the solution
This is an accepted solution.
How to Create a Clickable Image Lightbox on Your Shopify FAQ Page
To make an image on your FAQ page (such as a map) open in a larger popup when clicked, you can implement a straightforward solution using HTML and JavaScript directly within the Shopify page editor. Here's how:
Step 1: Insert the HTML Structure
Navigate to your FAQ page in the Shopify admin and locate the section where you want to embed the clickable image. Within the editor, use the "Show HTML" button (<>) to insert the following code:
<div style="text-align: center;"> <img src="{{ 'your-image.jpg' | asset_url }}" alt="Map" style="max-width: 300px; cursor: pointer;" onclick="openLightbox(this.src)"> </div> <div id="lightbox" style="display:none; position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.8); justify-content:center; align-items:center; z-index:9999;" onclick="closeLightbox()"> <img id="lightbox-img" src="" style="max-width:90%; max-height:90%;"> </div>
Important:
Step 2: Add the JavaScript Code
Immediately after the HTML code you inserted in Step 1 (still within the "Show HTML" view), add the following JavaScript code:
<script> function openLightbox(src) { document.getElementById("lightbox-img").src=src; document.getElementById("lightbox").style.display = "flex"; } function closeLightbox() { document.getElementById("lightbox").style.display = "none"; }</script>
Explanation:
How it Works:
This setup utilizes basic HTML for the image and the lightbox container, inline CSS for minimal styling, and JavaScript to handle the interactivity of opening and closing the lightbox. When a user clicks the image, the openLightbox function is called, making the hidden lightbox visible and displaying the clicked image within it. Clicking anywhere on the darkened background then calls the closeLightbox function, hiding the lightbox again.
This method provides a simple and effective image lightbox solution without relying on external apps or complex libraries.
Upload the full size image to your Shopify files:
Go to Settings Files, upload your image, and copy the URL.
Add this code to your FAQ page or custom HTML block where you want the image to appear:
html
Copy
Edit
-- Thumbnail Image
img src="https://your-cdn-link.com/map-thumb.jpg" alt="Map" id="mapImage" style cursor: pointer; max-width: 100%;
Popup Container
<div id="imageModal" style="display:none; position: fixed; z-index: 9999; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.8); justify-content: center; align-items: center;">
<span style="position: absolute; top: 20px; right: 30px; font-size: 40px; color: white; cursor: pointer;" id="closeModal"× span
<img src="https://your-cdn-link.com/map-full.jpg" style="max-width: 90%; max-height: 90%;">
</div>
JavaScript
<script>
document getElementById mapImage onclick = function
document getElementByI imageModal').style.display = 'flex';
document getElementById closeModal' .onclick = function
document.getElementById imageModal' style.display = 'none'
};
</script>
Replace both image URLs with the correct links to your thumbnail and full-size map image from your Shopify Files.
What this does:
When the user clicks the map, a full-size version pops up in the center of the screen.
A close (×) button lets them exit the popup and return to the page—no page reload needed.
This is an accepted solution.
How to Create a Clickable Image Lightbox on Your Shopify FAQ Page
To make an image on your FAQ page (such as a map) open in a larger popup when clicked, you can implement a straightforward solution using HTML and JavaScript directly within the Shopify page editor. Here's how:
Step 1: Insert the HTML Structure
Navigate to your FAQ page in the Shopify admin and locate the section where you want to embed the clickable image. Within the editor, use the "Show HTML" button (<>) to insert the following code:
<div style="text-align: center;"> <img src="{{ 'your-image.jpg' | asset_url }}" alt="Map" style="max-width: 300px; cursor: pointer;" onclick="openLightbox(this.src)"> </div> <div id="lightbox" style="display:none; position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.8); justify-content:center; align-items:center; z-index:9999;" onclick="closeLightbox()"> <img id="lightbox-img" src="" style="max-width:90%; max-height:90%;"> </div>
Important:
Step 2: Add the JavaScript Code
Immediately after the HTML code you inserted in Step 1 (still within the "Show HTML" view), add the following JavaScript code:
<script> function openLightbox(src) { document.getElementById("lightbox-img").src=src; document.getElementById("lightbox").style.display = "flex"; } function closeLightbox() { document.getElementById("lightbox").style.display = "none"; }</script>
Explanation:
How it Works:
This setup utilizes basic HTML for the image and the lightbox container, inline CSS for minimal styling, and JavaScript to handle the interactivity of opening and closing the lightbox. When a user clicks the image, the openLightbox function is called, making the hidden lightbox visible and displaying the clicked image within it. Clicking anywhere on the darkened background then calls the closeLightbox function, hiding the lightbox again.
This method provides a simple and effective image lightbox solution without relying on external apps or complex libraries.
Thanks Dc221.
It worked perfectly once I set up HTML section to use.
Then did i deserve like
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025