This repository contains custom code that enhances your Shopify theme. If a future theme update overwrites the customizations, follow these steps to restore the custom functionality.
custom-scripts.js
- Custom JavaScript for video functionality (mute/unmute, autoplay, etc.).media-with-text.liquid
- Modified Liquid template for media sections, enabling additional video controls customization.
Before making any changes, it's always a good idea to backup your current theme:
- From your Shopify Admin, go to Online Store > Themes.
- In your live theme, click the Actions dropdown and select Duplicate to create a backup.
- In your Shopify Admin, go to Online Store > Themes > Actions > Edit code.
- In the Assets folder, check if there is already a file named
custom-scripts.js
.- If it exists, click on it and go to Step 3.
- If it doesn't exist, proceed to the next step to create it.
- If
custom-scripts.js
does not already exist, click Add a new asset. - In the popup, select Create a blank file, name it
custom-scripts.js
, and click Add asset. - Copy the code from the
custom-scripts.js
file in this repository. - Paste the code into the
custom-scripts.js
file in your Shopify Admin and click Save.
- In your Shopify Admin, go to Online Store > Themes > Edit code.
- In the Sections folder, find the
media-with-text.liquid
file. - Copy the entire code from the
media-with-text.liquid
file in this repository. - Paste the copied code into the
media-with-text.liquid
file in your Shopify Admin, replacing any existing code, then click Save.
- In your Shopify Admin, go to Online Store > Themes > Edit code.
- In the layout folder, open the
theme.liquid
file. - Scroll down to just above the closing
</body>
tag. - Add this line of code to ensure the custom script is loaded:
<script src="{{ 'custom-scripts.js' | asset_url }}" defer></script>
- Click Save.
- Visit your store and navigate to a page where the media section is used.
- Verify that videos autoplay and the mute/unmute functionality works correctly.
- In the Shopify Customize editor, you should now see options to toggle video controls on or off.
In the Customize section of your Shopify Admin, when editing a page, you will now see an option to toggle video controls on or off in the media section. This setting is defaulted to "false" thanks to the media-with-text.liquid customization, meaning the controls will not show unless the box it toggled on.