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 an issue with a massive gap between the large image and slider. I tried it with and without the resizeObserver javascript and the issue persists. However, when resizeObserver javascript is active and you click a thumbnail the gap is no longer there and is working perfect. Issue is on the initial load before a user clicks a thumbnail.

Barry

Hi Made4Uo, yup, I have tried making my first photo as the large media in the shopify admin console. However, it’s not shown as the first item in the product slider.

climbingmountains

Hello

I appreciate the updates you continue to make! It’s been a big help! Thanks for adding the opacity. I made a small change to the line below to show the thumb for the large image that loads initially. Just wanted to share in case you find it helpful.

Kyle W

@Guido Magaldi May I inspect your website? You can messge me privately at “chat with us”

@Travis Glover Thank you

@Kyle W – I added the code in green for that matter. I also went ahead and added a borderbox too.

Thank you everyone!

Made4Uo

Great solution! Thanks so much for sharing! Curious if you would know of a simple way to add opacity to the slide images so that the active slide is clear while the others have opacity over them so the user can easily see which image they are viewing?

Kyle W

Leave a comment