Add an image preview to the product page

Adding an image preview to the product page is a great way for customers to ensure they've uploaded the correct file. Follow the steps below to get started.

Note: This will only work with rasterized files (.png, .jpg, .jpeg, and .gif).

ImagePreview

Getting Started...

1. Starting from your Shopify admin dashboard, click on Online Store, then click on Themes.

2. Find the theme you want to edit, click the Actions button, then click Edit code.

3. Open the product.liquid file, located in the Templates folder.

4. Paste the following code snippet at the bottom of that file.

<script>
$(function() {
  $(document).on('previewSuccess', 'form[data-uploadery]', function(e) {
    if (e.originalEvent.detail.preview === '') {
      return;
    }
    var $title = $('<p></p>').html('Preview:');
    var $img = $('<img/>').attr('src', e.originalEvent.detail.preview);
    var $uploaderyResponse = $('<div></div>').attr('class', 'uploaderyResponse').html([$title, $img]);
    $('.uploaderyResponse').remove();
    $(e.target).after($uploaderyResponse);
  });
});
</script>

5. Open the  Assets folder, then navigate to your theme's main CSS file (this file is commonly named timber.scss.liquid, theme.scss.liquid, stylesheet.scss.liquid, and style(s).scss.liquid).

6. Paste the following code snippet at the bottom of the file.

.uploaderyResponse {
  display: inline-block;
  width: 100%;
  max-width: 50%;
  text-align: center;
  padding: 10px;
  background: #F5F5F5;
  box-sizing: border-box;
  border: 1px solid #ececec;
  margin-bottom: 25px;
}

.uploaderyResponse p {
  width: 100%;
}

7. Save your changes.

If you need any help getting this set up, feel free to contact our support team. We'd be happy to help out!

Still need help? Contact Us Contact Us