2

I'm trying to use the "Embedded Assets" Craft plug-in to embed Youtube videos in my content, but I can't figure it out. I've read through the instructions on the Github page, and I've looked at other resources online, but it's not working and I can't make sense of it.

I have successfully installed the plug-in, and it seems to be "grabbing" the videos correctly because a thumbnail for the video appears when I enter the URL for it in the "Embed link" Asset selection. These are also saving in their respective fields when I enter them into an Entry.

Where I'm having trouble is understanding how to integrate them into my templates; the only configuration I changed was the 'extraAllowedFileExtensions' => 'json' setting in the general.php file. It said something else about configurations in the documentation, but it was very vague and said their should already be defaults in place. I tried dropping the code in that they suggested, as well, and played with the values a bit, but it's just empty space when I preview the page (or it breaks the page altogether).

Here is the code I tried to put into my template in different forms (tried the given loop, not looping, and etc.):

{% for asset in assets %}
    {% set embed = craft.embeddedAssets.fromAsset(asset) %}
    {% if embed %}
        {{ embed.safeHtml|raw }}
    {% endif %}
{% endfor %}

If you care to write an example, the handle for the field I'm using is embeddedMediaUrl and the embed links are stored in assets/mediaEmbeds (not sure if this info is needed or not.)

Any and all help with this will be greatly appreciated. I apologize if this is vague, but I've been messing around with it long enough that it seemed time to reach out to the community to see if someone could give me some help. Thank you.

2
  • Are you using the latest version of the plugin? Previous version had a bug where the embeds weren't outputted in the templates if in the assets source setup you were using environment variables, for example {siteurl}/mediaEmbeds.
    – pauliusef
    Mar 10 '17 at 9:56
  • Thank you for the reply. Yes, I did download the latest version... I just know it's some silly thing I don't have written out quite right! :P
    – scoffin
    Mar 10 '17 at 15:32
1

Author of EA here. Adding in that extraAllowedFileExtensions config setting is about all you need to do. Any other configuration is just for "power" users (for lack of a better term) and you shouldn't need to worry about them.

There's many reasons why you might not be seeing anything show up in your templates. You also said it sometimes breaks the page altogether? Can you please elaborate on this? Are you running in dev mode? If there are any errors, what are they?

It might be better for you to post this as an issue on the Github page, so it can be more of a discussion. I don't really have an answer for you as I don't yet know what the cause of the problem is.

1
  • Thanks for the response, Benjamin! Love the plug-in, even though I haven't quite unlocked it's potential yet. I'll try to come back around and give more detail on the issue soon-- Unfortunately got pulled away from the project to work on something else though, so it may be a little while before I can sit down and provide the necessary detail.
    – scoffin
    Mar 10 '17 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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