top of page

Custom Product Pages on Wix: Part 2 Displaying Product Media Items

Customizing the appearance of media items can enhance the look and feel of your product page. A high-quality product image and aesthetic design can make the product more appealing to customers and capture their interests because what they see can influence what they buy. Integrating interactive functionalities such as sliders, toggle buttons, and zoom-in and zoom-out can also engage customers and enhance their shopping experience, which can drive more sales.


If you want to customize the appearance of media items on your product page, then you've found the right guide.


This article will walk you through the step-by-step process of displaying media items with interactive functionalities on your product page.



Want to learn more? Ready to dive deeper into Wix and Velo? Take your skills to the next level with our comprehensive 'Velo for Beginners' course on Udemy. Enroll today to uncover the intricacies of Wix and Velo.


Need help with your site? The Wix Wiz team is at your side. Schedule a one-on-one consultation or have the entire team onboard with our development and support plans.


To customize our product page, we are implementing the look and feel of this Etsy product page. In our previous article, we explained how to set up the foundation of a custom product page; you can check it out here.

 

In this article, we will implement all the image functionalities on the Etsy product page. This involves displaying main and smaller images, adding a border background color to indicate selected images, and arrow buttons to toggle between previous and next images on our Wix product page.


Let’s get started


How to Display Images Using a Repeater


A repeater provides a way to display a list of items with the same design and layout but different content. With this, we can display multiple images with the same design and layout.


The first feature we want to implement on our product page is to use a repeater to display smaller side images.


Step 1: Navigate to your dynamic product page.

Step 2: Crop the main image to the dimensions of the Etsy product page.



Wix editor interface showing a coded page layout. An image placeholder with a blue mountain and sun icon is selected on the right.

Now, let’s split the strip into two columns. This is to arrange the images on the right side and the left side for texts and other features.


Step 3: Click the ‘Layout’ icon and select ‘Add column.


User interface showing a "Strip Layout" menu in a design tool. An arrow points to "Add Column." Options for content alignment are visible.

This should appear on your screen.


Interface with a sidebar, editing tools, and a blue image icon showing a sun and mountain. Options include "Change Image" and "Edit Image".

Since we only want to arrange our images on the left side, then we need to delete the image on the right side.


Step 4: Left-click the image and click the delete button. 


Image editor showing a context menu with options like Edit, Cut, Copy, and Delete highlighted by a red arrow, on a blue and white interface.

The next thing is to design the main image by giving it a round edge shape just like the design on the template.


Step 5: Click the ‘Design’ button and select an image frame with a round edge shape.


UI showing an image placeholder with a sun and hills under "Image Frame Design." Options with bicycle frames visible.

The next step is to display the smaller images using a repeater. Our product will use this to populate the images from our data.


Step 6: Click the ‘Add Element’ button and select the ‘list’ option.


Interface screen displays options for adding elements with images, colored circles, and text options. A red arrow points to "List" under "Interactive."

Step 7: Click the ‘Blank repeater ’ button and select an item from the list.


Interface showing "Add Elements" menu in a design tool with options like Blank Repeaters and Tables. A red arrow points to a tooltip: "To add, just drag and drop."

Step 8:  Crop the container to the size of the smaller image we want to add.


UI design interface with a blue sidebar, repeating container layout, and labels: "Repeater #repeater1" and "Container #container1".


Step 9: Readjust the repeater to align each container into a row.


Web design interface with blue image placeholder on left and column management options on right. White background with tool icons.

Step 10: Adjust the position of the repeater.


Blue and white abstract image with geometric shapes, a sun and mountain. It is on a webpage with gray boxes and "Manage Columns" text.

The next step is to add Images to the repeater


Step 11: Click ‘Add Element’ and navigate to the ‘Image’ option.


Step 12: Select a random image from the list. This image will be replaced later with our preferred product image.


Wix interface showing a 3D pink strawberry with green leaves. Options for images and logos are visible. Text reads "3D Strawberry."

Step 13: Crop the image to fit the size of the container in the repeater.


Pink strawberry image on blue background with digital editing icons and tools visible, creating a modern, tech-focused design mood.

Step 14: Adjust the design to give it a round edge.


Web editor with UI elements for a product page. Previews bicycle photos, a red object, and options for editing image frames.

Step 15: Replace the image ID with a more unique name. 


UI with a partially visible strawberry image, editing options, code snippet on product image handling, and a pink arrow pointing right.

Step 16: Drag the image to place it inside the repeater.


UI showing three pink polka dot bowls stacked vertically, with image editing options and a light blue, triangular graphic background.

Step 17: Replace the repeater ID with a more unique name.


Interface showing a design tool with a vertical row of three red and white dotted ovals on the left and a blue shape on the right. Text box labeled "mediaRepeater" is highlighted.

Step 18: Replace the main image ID with a more unique name.


HTML editor displaying a script for product image handling, with three red textured images and a blue placeholder image in the layout.

The next step is to connect these elements to the actual media from our product using the Wix code


Recall that in our previous tutorial article, we dynamically added our main image using `("#dynamicDataset").getCurrentItem();` to retrieve all of the product data since this dataset is linked to the product item from the product collection. Then `$w("#mainImage").src = product.mainMedia;` replaces the main image with the image in our product data.


Code snippet for a Velo API setup in Wix is shown. Comments and code include references and functions for dynamic dataset and images.


Since we have added our main image, the next step is to populate the repeater with images from our product data. This will automatically replace the current placeholder images in our repeater with actual images from our product data.


To do this, we need to create a function that populates the repeater with images from our product data.


Step 19: Create a function.


Code snippet of a JavaScript function for fetching product data in Wix, with a pink arrow pointing to a specific line. Background shows UI elements.

Step 20: Use the `map` function to iterate over all the elements in the product data.


Code snippet for a product page on Wix, displaying JavaScript with Velo API for loading media items. Text at top: "Products (Item)".




The `map()` method iterates over all the data in the `product` array, targeting only the `mediaItems` data. This will only retrieve the image data we want to display in the repeater.


 The `item` parameter represents all the data in the `mediaItems` and the `index` parameter represents the index of each data in the array.


Inside the callback function, `...item` spreads all the data in the `mediaItems` array, and `_id: index.toString()` is used to manually add a string ID with an underscore to each data. This is because the ID of a repeater must be a string with an underscore.

Then this data is stored in the `mediaData` variable.


Step 21: Populate the repeater with the product data.



Screenshot of JavaScript code in a development interface. It's related to Wix Velo API, focusing on product and media data handling.


The repeater is automatically populated by targeting its ID of `mediaRepeater` and using the `.data` property to set the repeater data to the data in the `mediaData` variable.


Step 22: Create an `onReady` function to tell the repeater how to display the images once the data is populated.


Code editor showing JavaScript with a red arrow pointing to line 7. Comments and functions about media handling are visible.



The `onItemReady` function is added to the `mediaRepeater ID` to execute an action once a new repeated item is created. 


In the callback function, `$item("#media")` tells it that inside of the repeater, each item will act differently based on the data of that specific item. Then the `src` attribute is used to set the location of the image to the image in our item data. I.e.,  the image in our product data will automatically be displayed in the repeater.


Step 23: Invoke the `populateRepeater` function to execute the code.


Code snippet for a Wix API introduction with highlighted line 24. The code includes functions for media and datasets. A red arrow points to the highlight.

Your code should look like this:




Step 24: Click the ‘Preview’ button to view the live changes.


A beige vase with pink flowers on a textured surface against a green background. The image has a minimalist and serene mood.


Notice that other images have been populated in the repeater!


The next thing is to add more functionality to the images.


In the Etsy product page we want to implement, clicking any of the smaller images will dynamically change the main image and a border background also appears around the image to indicate it has been selected.




How to Dynamically Change the Main Image on a Wix Product Page


The functionality we want to implement is to dynamically change the main image once the smaller image is clicked and add a black background color to indicate that the image has been selected.


Step 1: Navigate back to the editor.


Step 2: Add an `onClick` event listener to dynamically change the main image once any of the smaller images are clicked.


Code snippet from Velo by Wix API shows functions for handling media display. Comments and a red arrow indicate focus on the item setup.



The `onClick()` function is attached to the image. Once the image is clicked, it triggers an action to dynamically change the main image by targeting its ID and then using the `src` attribute to change the image location to `itemData.src`, which represents the location of the image clicked.

This will dynamically change the main image.


The next functionality we want to implement is to indicate that the image has been selected by adding a border background around the image.


To achieve this, we need to change the container background in the repeater.


Step 3: Click the container in the repeater.


UI design interface showing strawberry images within a container and repeater. Blue background with a white heart symbol. Tool options displayed.

Step 4: Click the ‘Design’ icon and select the ‘Border’ option to make the container completely transparent.


Web design interface with a pink strawberry image highlighted. A sidebar shows item design settings with opacity at 0% and border width at 15px.

The next step is to add a new container box inside the repeater. This is the box we will add a background color to any time an image is clicked.


Step 5: Click the ‘Add Element’ icon and navigate to the ‘Box’ option.


Interface showing "Add Elements" with options like Text, Image, Button. A tooltip says "To add, just drag and drop." with colored boxes visible.


Step 6: Click the ‘Container Box’ option and select a round-edge box.


Interface showing "Add Elements" menu with boxes and navigation on the left. A red arrow points to purple shapes under "Container Boxes."

The next step is to change the container box background color to white.

 

Step 7: Click the ‘Change Design’ button to change the background color of the container box.


A digital design interface shows a pink bowl pattern, blue mountain background, and a purple design box with "Change Design" and "Customize Design" options.

Step 8: Click the ‘Customize Design’ button and navigate to the ‘Fill Color & Opacity’ option.


Design interface showing pink strawberry images on left, blue-purple box design on right with a menu open, and a red arrow pointing to fill color option.

Step 9: Click the small box container beside the 100% button.


Image editing interface with three pink textured strawberries on the left. A purple design box is selected with a "Change Design" option visible.

Step 10: Change the color to white.


Web design interface with pink textured bowls, design customization tools, and code editor. Blue and gray color picker visible.

Now that we have a container box, the next step is to place it inside the repeater.


Step 11: Place the image outside the repeater.


Interface screenshot with a sidebar and tools. A strawberry-like object on a blue background. Options like "Manage Columns" are visible.

We need to add a round edge to each container in the repeater to make it look exactly like the implementation we want.


Step 12: Select the container in the repeater, click the ‘Design’ icon, and select the ‘Corners’ option.


UI design dashboard with a layout grid. An orange border highlights a section. A blue panel shows "Item Design" with options: Border, Corners, Shadow.

Step 13: Add a radius value to the border.


UI screenshot of a "Box Design" menu, showing shape options and corner radius settings. Dominant colors are blue and white.


Now that we have adjusted our container, the next thing is to place the container box inside it.

You should also give the container a round edge so that it can fit the size of the container.


Step 14: Place the container box inside the repeater.


Interface showing design elements. Orange boxes highlight sections labeled "Repeater" and "Container Box." A blue design preview is visible.

Step 15: Place the image back inside the repeater.


Close-up of two pink strawberries on left; on right, a blue screen with a heart graphic. Editing tools overlay the image.

Now, we can add a background border to the container box using Wix code.


Step 16: Give the container box a unique ID.


Design software interface with strawberry images in a container box, code editor below showing JavaScript, and a highlighted element ID.

Step 17: Add a white background color to the container box.


Code snippet showing JavaScript with a highlighted line by a red arrow. The background is a light pastel color.



A white background color is added to the container box using its ID of `containerBackground` and applying a white background color to it. 


Step 18: Add a black background to a selected image.


Code snippet in a text editor includes JavaScript for a Wix site. Lines are highlighted, and text colors are blue and black.



The `$item` selects the specific item clicked,  gets its ID of `containerBackground`, and adds a background color of black to it.


This will automatically add a background to any image clicked, while other images will have a white background.


Your full code should look like this:




Step 19: Preview to view the changes.


Beige vase displayed on a white background with smaller thumbnails; one has flowers. Wix ad visible at top, set in a web design preview.

Notice the main image is dynamically replaced once any of the smaller images is clicked and the selected image also has a black background color to indicate it has been selected.


One more functionality we want to implement is to select one of the images by default with a black background color when you just visit the page.



A golden-brown bean pie on a white plate with fork beside it. Price is USD 15.99+ from Imani's Originals with high star ratings.


To implement this, we need to set a conditional statement and add a background border color to the first image.



Step 20: Navigate to the editor.


Step 21: Add an index parameter to the `onItemReady` callback function in the media repeater.


Code snippet with a pink arrow pointing to a section. Background is a text editor displaying a JavaScript function, with commented references to Wix Velo API.

Step 22: Use the `if` statement to set the condition.


Screenshot of JavaScript code for a Wix Velo API. The code includes comments, functions, and is highlighted by a pink arrow.


This checks for the first item and adds a black background color.


Step 23: Click the preview button to view the changes.


How to Add a Back and Forward Button to Images on a Product Page


The next functionality we want to implement is to add a back and forward button to the product page. Clicking the forward button should display the next image, while clicking the back button should display the previous image.


To achieve this, follow these steps: 


Step 1: Navigate to the editor.


Step 2: Add an arrow button to the page.


Wix UI screen showing button options. A red arrow points to a teal up arrow icon. Code snippet visible below.

Step 3: Change the background color of the button to white.


Design software interface with "Button Design" and "Fill Picker" panels. Pink textured pattern on left. Blue and grey theme colors visible.

Step 4: Click the icon button to change the arrow's color. 


UI screen showing button design settings next to pink, textured icons. Options include Background fills, Text, Borders, and Icon.

Step 5: Change the color to black to make it visible on the white background.


UI design interface with "Button Design" and "Color Picker" panels. Strawberry images align vertically. Theme colors and sliders visible.


Step 6: Navigate to the ‘Shadow’ option and select ‘Blur.’


UI screenshot shows a button design menu with Shadows highlighted. Pink strawberry images are behind, and various design options are visible.

Step 7: Click the ‘Add shadow’ icon and add a blur effect.


UI of a design tool showing button design options. Pink berry pattern on the left. Shadows settings box active with 19% shadow.

Your arrow button should look like this.


Three pink strawberry icons in a column beside a blue graphic. Arrows and options for "Manage Columns" and "Change Background" visible.

Step 8: Left-click the arrow button to duplicate it. Then, place the second icon on the right side.



Pink 3D strawberries on the left, images with a blue placeholder icon on the right. Arrows for navigation are centered below each section.

Step 9:  Click the arrow button and click the small ‘Rotate’ icon to rotate the position of the arrow button.


UI design with pink strawberry icons on the left, blue background on the right, and a red arrow pointing to a "Button" with settings tools.


Step 10: Rotate both arrow icons.


Now that we have set up our button, the next step is to add an `onClick` event listener to each button to trigger an action once the button is clicked.


Before doing this, let’s create a global variable representing the product. This is to avoid any confusion because when using the WIX API, we often need to use the word product.


Step 11: Create a global variable. This variable will store all the information about our product.


Code snippet for a Velo API function in an IDE. Lines of JavaScript manage image loading and background color change for a media element.


Step 12: Replace all variables representing the product with the new variable you just created. This is to prevent the code from breaking.


Highlighted code with pink arrows in a programming interface. The script manages media items, modifies styles, and populates a repeater.


Step 13: Give the arrow buttons a unique ID.



Step 14: Create another global variable and set its value to 0. This is to keep track of the media we are currently clicking.



Code snippet in an editor shows JavaScript with comments. A red arrow highlights line 6. Background is white with black text.



Step 15: Add an `onClick` event listener to each button.



Code editing screen showing JavaScript for media buttons. Significant lines are highlighted in red. White background with black text.


Step 16: Increase the media item count by 1 once the next button is clicked. This will change the current main image to the next image


Highlighted JavaScript code snippet with a red arrow pointing to "onClick" function. The background is a light code editor interface.




Inside the event listener, the code first checks if the `currentMedia` index is at the last item in the `mediaItems` array. If it is, the function exits without doing anything. Else, it increases the `currentMedia` index by one and updates the `src` property of the `#mainImag` element to display the next media item.


Step 17: Decrease the media item count by 1 once the next button is clicked. This will change the current main image to the previous image.



Code editor displaying JavaScript function for a media player. A magenta arrow points to a button click handler in the code.






Inside the event listener, the code first checks if the `currentMedia` index is at the first item (i.e., index 0) of the mediaItems array. If it is, the function exits without making any changes. Else, it decreases the `currentMedia` index by one and updates the src of the `#mainImag` element to display the previous media item.


Step 18: Click the preview button to see the code in action.





The buttons are working as expected; the next button displays the next image, while the previous button displays the previous image.


The last functionality we want to add is to ensure that the black border appears on the selected image each time the button is clicked, just like it is on the Etsy product page.


Step 19: Create a function that targets the selected image and adds a black background color to indicate it has been selected.


Code editor screen with JavaScript code, featuring a red arrow pointing to a specific section. White background with blue, black, and green text.






In the `mediaItemHandlerButtons` function, the `forEachItem()` function iterates over all the data in the repeater using its ID `mediaRepeater`, and then the `if` statement checks if the index of the image that is currently displayed is equal to the index of the image the user selected.


If this condition is true:


  • The main image is updated to the currently selected image (itemData.src).

  • The background color of all images is set to white().

  • The background color of the selected image is set to black.


Then, if this condition is not met, nothing changes.


Step 20: Invoke the function inside the `onClick` event listener of each arrow button.


Code editor showing JavaScript for media controls; includes red arrows pointing at lines 64 and 75. White background, gray scrollbar on right.


Step 21: Click the preview button to view the changes.





Notice that a black background color is added to each selected image once the arrow button is clicked!


We have successfully implemented all the image functionalities on the Etsy product page.


Conclusion 


The way media items are displayed on your product page impacts sales because this is where users get to see the pictorial representation of what they want to purchase. Using aesthetic designs, high-quality images, and interactive functionalities can compel them to buy such items. 


In this tutorial article, we customized the media items on our product page by implementing several functionalities, such as displaying main images and smaller images, a border background color to indicate selected images, and the arrow buttons to toggle between previous and next images on our Wix product page.


But there’s more! In our next article, we will explain how to display product information on our Wix product page.


Want to learn more? Ready to dive deeper into Wix and Velo? Take your skills to the next level with our comprehensive Velo for Beginners course on Udemy. Enroll today to uncover the intricacies of Wix and Velo.


Need help with your site? The Wix Wiz team is at your side. Schedule a one-on-one consultation or have the entire team onboard with our development and support plans.


 
 
 

Comments


RESOURCES

Become part of a thriving community

CONTACT US

Let's Make Some Magic!

Have a project in mind? Question? Just want to say hi?

Get in touch, and let’s bring your vision to life!

CONTACT INFORMATION

WHAT IS THE NATURE OF INQUIRY?

WHAT IS THE NATURE OF YOUR INQUIRY?
bottom of page