{% import '_includes/forms' as forms %} {% set fieldId = 'link-embed-' ~ random() %} {% set data = link.getData() ?? [] %}
{{ forms.text({ id: fieldId, value: data.url ?? null, placeholder: link.placeholder ?? link.linkValuePlaceholder(), inputAttributes: { 'data-value': data.url ?? null, }, }) }} {{ hiddenInput('linkValue', data | json_encode, { class: 'link-embed-data' }) }} {% if data %}
{% endif %}
{% css %} .hyper-embed-field { position: relative; } .hyper-embed-field .spinner { position: absolute; top: 0; right: 5px; } .hyper-embed-field .favicon-icon { position: absolute; top: 5px; right: 5px; width: 24px; height: 24px; border: 1px #fff solid; border-radius: 4px; overflow: hidden; } .hyper-embed-response > * { margin-top: 0.5rem; } {% endcss %} {% js %} new Craft.Hyper.Embed('#{{ fieldId | namespaceInputId }}'); {% endjs %}