2

In the example from the documentation on Craft 3 'Video Embedder' plugin:

{% 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.

2 Answers 2

1

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 %}
1

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:

Embed\Exceptions\InvalidUrlException

<url> malformed

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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