Product Image slider for Shopify Dawn theme - version 2.4 and lower

Product Image slider for Shopify Dawn theme - version 2.4 and lower

Log in or Sign up to ensure access to FREE code across multiple devices.

This only works with Dawn 2.4 and lower. Check this video on how to see your theme version link.
Did you use Dawn theme and was disappointed that they do not have a product slider?
Don't worry. In this tutorial, we will create one.
Recommendations: I also created a code to transform Dawn product page like Debut theme with a slider. Check link.
  1. Go to your Online store > Themes > Actions > Edit code
  2. Go to Section folder and open the main-product.liquid
  3. Find <slider-component> block and comment it out or delete it if you want

Comment it out by placing “<!--” before the slider-component and “-->” after the slider-component. Code should look like below

   

      4. Before the commented out <slider-component>, add the code below



       5. On the top part, paste the code below, and click SAVE

 

       6. I see that the component-slider.css is also being use for multi-column section, therefore, we have to create a new .css file. Go to Asset folder, click 'create new asset', create blank. Name the file 'product-slider'. File should show like below

 

     7. Now open, the created CSS folder and paste the code below.


    8. Next, go back to the main-product.liquid. At the top part, comment out this code. You can also just delete it. To comment it out, place (<!-- ) before the code and (--->) after. Just like we did in the slider-component. Code should look like this.

add this after. 

 

    9.  We need to go to the Asset folder again, and open global.js. Find the slider-component. Since slider component is a global code, meaning, some section also uses the same code. We have to add an if statement. Please disregard the video regarding this section in global.js.

At the SliderComponent constructor add the code below.

   10. At the initPages function we need to change the totalPages. Replace the code below:

 with this

    11.  Lastly, at the update function we need to change the currentPage, change the 1 into 4. Replace the code below, and click SAVE

 to this

 

The global.js code should look like this:

That's it! You just transform the product page of Dawn theme. Let me know if you have questions or having issues with the code so we can fix it and have an updated code. (",)

 

Update 09/22/21: I end up changing the the code in the Asset/global.js so we do not break the slider component if we use it in the other section

I change the CSS code and remove the resize observer. Large-image will be the same height with the large-image-item.

Update 09/23/21: Issues of having two large image and slider missing fixed. Updated code to use feature hide_variants 

Update 09/25/21: Fix the issue with thumbnail disappears when adding a section that uses a slider-component. Updated the code in the step #4.

Update 09/26/21: Added a video play button when thumbnail image is a video

Update 09/30/21: Fix the issue regarding the video button. Reposition the codes for the video-btn and added some css codes

 Update 10/01/21: Fix the issue of stacking large images in mobile. I added a resizeObserver in the Javascript to fix the issue of big gaps between the large-image and the slider. If you don't want it you just delete the code

Update 10/03/21: Added overflow: hidden to large-image css. I would recommend not to have product images with extreme height as your first variant image. Also added some CSS so when active, thumbnail image will have border box and opacity is 1. See code in green. Thumbnail border color is dependent on your var(--gradient-base-accent-1)

Update 10/04/21: Change the v-btn in the product-slider.css file due to issue when having a mobile video

 Update 10/10/21: I know I fix the issue regarding the space between the large image and the slider. I did remove the resizeObserver and also the padding-bottom of the large image to fix this. I updated the code

Update 10/11/21: I change how the border and opacity is applied. Please see the highlighted green code

Update 10/15/21: I added an onload function so when the window loaded the first image in the thumbnail will get the active property. Code is pink. 

Also added a code for those who still want the option to hide the variants when variants selected. (NOTE: this is the original code from Dawn). See code in blue.

Copied!

Struggling with instructions?

Don't worry, we've got you covered for a reasonable price.

Contact us through "Chat with us" for a quote.

Relax as we handle it for you!

Back to blog

46 comments

I have a suggested quick fix:

On product-slider.css:

.slider-container {
margin: auto;
width: 100%;
overflow: auto;
display: flex;
flex-flow: column wrap;
align-items: center;
position: relative;
}

I changed the margin: auto instead of margin: 0 1rem; because it is not centered on mobile.

Re: the slider arrow issue, I get it. It shows up if the product images are 5 or more but it appears as "4 / 5 " instead of starting to 1 /5. It is not also updating the number when you select random product image.

need help *

by the way, thanks a lot for posting this tutorial. Will also try to contribute the fixes that I will discover as I work on this :)

eunice

followed your latest update in the blog post. Images work fine as expected but the slider arrow that should be placed below the images has disappeared…

eunice

Awesome. Is there any way to add the function to change the variant selection by clicking the thumbnail image? Thanks.

Charles

Hi Guy,

Thank you for leaving a comment. I updated the code. Let me know if you are still experiencing some issues.

Made4Uo

Is it possible to give the main image container a max pixel height? I’ve added my images but they are too big on the page (in my opinion) I’ve tried changing the sizes of the images themselves but that didn’t do the trick. I like the image carousel and all of the images within to be fully visible without scrolling.

Guy

Leave a comment