Comments (3)
Hi @benjamminf , no worries! I did do something along the same lines as you suggested, and I understand you wanting to adhere to the oEmbed specs.
Thanks for getting back to me though :)
from craft-embedded-assets.
Hey Rob, sorry for the late reply!
EA is built to accept any link that contains oEmbed data. This means the plugin won't contain any special cases for things like extracting YouTube ID's.
That said, this is something you could do quite easily in your Twig template:
{% set embed = craft.embeddedAssets.fromAsset(asset) %}
{% if embed.providerName|lower == 'youtube' %}
{% set videoId = embed.url|replace('/.+watch\\?v=(.+)/', '$1') %}
{% set modalUrl = 'https://www.youtube.com/embed/' ~ videoId %}
{% endif %}
This will use a regular expression to find the ID from the YouTube URL.
from craft-embedded-assets.
How could we use this solution for multiple videos in the same field?
{% set asset = block.videoAsset.all() %}
{% for asset in block.videoAsset.all() %}
{% set embeddedAsset = craft.embeddedAssets.get(asset) %}
{% if embeddedAsset.providerName|lower == 'youtube' %}
{% set videoId = embed.url|replace('/.+watch\\?v=(.+)/', '$1') %}
{% endif %}
...
https://youtu.be/{{ videoId }}
{% endfor %}
from craft-embedded-assets.
Related Issues (20)
- The "Uploaded By" field is empty or does not exist after adding the embedded asset HOT 1
- Type Error HOT 1
- Where do I set the embedded data? HOT 1
- Sk
- getVideoId not working with Dailymotion HOT 4
- TikTok URLs can't be added HOT 1
- UX: Moving of assets not possible HOT 2
- Limit What Volumes Can Use Embedded Assets HOT 1
- Limit Asset Selection by Type HOT 1
- Limit urls by domain (example youtube only) HOT 2
- Direct vimeo urls in Craft 4.4.5 don't work HOT 1
- Google maps embed only returns a link HOT 2
- Error embedding Instagram: max 10 redirects followed HOT 1
- Twitter embeds HOT 1
- Failed queue jobs for Checking whether Instagram embedded asset needs to be refreshed
- How to use in module/plugin HOT 1
- Wistia embed support? HOT 7
- Can't embed youtube/vimeo videos now HOT 2
- TypeError: Cannot read properties of undefined (reading 'folderId') HOT 10
- Include Inputs to capture required Craft asset field values HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from craft-embedded-assets.