Setup

Limitations

  • As soon as the editor is launched, a template size that has been chosen cannot be modified.
  • Only templates with the same aspect ratio as the selected size will be displayed in the template panel.
  • The minimum template size must be 90x90 px.
  • The maximum template size must be 7550x7550 px or 2000x2000 mm.

Generate script

<script src="https://content.wepik.com/scripts/wepik-button/1.0.5/wepik.js"></script>
<script>
    const editor = WepikButton.initialize('API_KEY', {
        lang: 'en',
        category: '',
        height: 1000,
        width: 1000,
        unit: 'px',
        format: 'jpeg',
    });
    const button = document.createElement('button');
    button.innerText = 'Open Editor';
    button.style.padding = '1rem';
    button.style.borderRadius = '0.75rem';
    button.style.border = 'none';
    button.style.backgroundColor = '#1a1a1a';
    button.style.color = '#fff';
    button.style.cursor = 'pointer';

    button.addEventListener('click', () => {
        editor.open();
        editor.onPublish((data) => alert(data.url));
        editor.onClose(() => {
            alert('close');
            editor.close();
        });
    });

    document.body.appendChild(button);
</script>