How can I use masks to crop the live preview?

The layers on the live preview can be cropped into any kind of shape.

Follow the steps below to learn how to set it up.

Example:  

You can view the Live example on the Demo store:  https://www.cloudlift.app/collections/live-product-options/products/live-product-options-mask-shapes

Setup

There are two different techniques to achieve a cropped preview.  

You can either use a PNG image overlay with transparent parts (simpler) or a custom SVG mask (advanced).

1) PNG Overlays:

Create a png image that is transparent where the image should be visible. The transparent parts act as a way to crop the preview layer:

Note: This image is just an illustration of the transparent parts, a real transparent version can be found here. 

In the live preview, add a layer of type "Overlay" and upload the png image with the transparent parts. 

Move the layer at the very bottom (to show it on top):

Any image below this layer will now only show the transparent parts:

The overlay image must have transparent areas. A JPG cannot carry it at all, and a PNG that was flattened or exported on a solid background has lost it. Because the overlay sits on top of every layer below it, an image without transparent parts covers the whole preview: all you see is the overlay image itself, with the uploaded image and the product image hidden behind it. When the overlay artwork is dark, the result is a live preview that looks completely black or blank, in the editor as well as on the product page.

If your preview goes black after you add or replace an overlay:

  1. Open the layer and check the image. A .jpg  is always the cause. A .png  can also have been flattened, so confirm it really has a transparent area and not a white one.
  2. Re-export the artwork as a PNG with a transparent area where the customer's image should show through. In an image editor, delete or mask that area rather than filling it with white. White is opaque and hides the layers below.
  3. Save the layer and reload the preview.

To test which layer is responsible, hide the overlay layer temporarily. If the preview then renders, the overlay image is the problem.

2) SVG Mask: 

Create an SVG file with a shape that defines the outlines of the crop:

Keep the SVG as simple as possible, it's best to use a single <path> element:

<svg xmlns="http://www.w3.org/2000/svg" xml:lang="en" height="20px" width="20px">
    <path fill="none" stroke="#000" stroke-width="0.1" d="M10,6 Q10,0 15,0 T20,6 Q20,10 15,14 T10,20 Q10,18 5,14 T0,6 Q0,0 5,0 T10,6 Z"/>
</svg>

In the live preview, add a layer of type "Mask":

The app comes with pre configured shapes. Select svg to upload your own shape:


By default, the SVG mask is applied to the full preview and stays static on the preview.

Area=Box setting is not supported on the full preview.

Mask layers

You can configure to apply a mask to specific layers only:

Mask fixed position

By default, the mask is applied to the individual layers and is moving with the layer.

If you want the mask to be static on the preview, you can enable the Fixed position setting:

Fixed masks also support Area=Box setting to only apply the mask to a specific area:

Example templates

You can find example templates for both techniques in the Templates page inside the app:


Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.