Craft 3 'Video Embedder' plugin help please!

In the example from the documentation:

{% set embed = craft.videoEmbedder.getEmbedUrl('https://www.youtube.com/watch?v=6xWpo5Dn254') %}

{% if embed | length %}
    <iframe src="{{ embed }}"></iframe>
{% endif %}

Can someone please give me full (i.e. total beginner!) instructions on how to get the URL to load. Many thanks!


Worked it out - just needed to use the right syntax, for example:

{% set embed = craft.videoEmbedder.getEmbedUrl(entry.videoEmbed) %}

{% if embed | length %}
<div class="embed-responsive embed-responsive--mb-l embed-responsive-16by9"><iframe src="{{ embed }}" width="100%" height="600" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div>
{% endif %}

Unfortunately, it has causes a big PHP error if 'empty'...If you don’t have any content (i.e. it’s an optional field for someone to add a video embed to the page and the user chooses not to embed a video) it triggers a big PHP error:


<url> malformed

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.