mikestecker / craft-videoembedder Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
I currently get the following error when a field for the URL is empty:
Embed\Exceptions\InvalidUrlException
malformed
As far as I can tell my code looks fine:
{# Video Block #}
{% set videoUrl = block.video %}
{% set videoEmbed = craft.videoEmbedder.getEmbedUrl(videoUrl) %}
{% set providerName = craft.videoEmbedder.getProviderName(videoUrl) %}
{% if videoUrl | length %}
<div class="{{ padding }} {{ fontsize }}">
<div class="{{ margin }}">
{% if providerName == 'YouTube' %}
<div class="aspect-ratio aspect-ratio--16x9">
<iframe class="aspect-ratio--object" src="{{ videoEmbed }}" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
{% endif %}
{% if providerName == 'Vimeo' %}
<div class="aspect-ratio aspect-ratio--16x9">
<iframe class="aspect-ratio--object" src="{{ videoEmbed }}" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
{% endif %}
</div>
</div>
{% endif %}
All videos across our whole site have disappeared. When I look at the back-end, it looks like the Video Embedder plug-in just stopped working, but I can’t find any reason for it to do so. The same thing happened Jan 20, 2020 and after a few hours it suddenly started working again. The plug-in is not functioning again now, Jan 27.
The field type is still “Video.” When I go into an entry that was working just earlier today and showing a preview of the video in the back-end, the preview is no longer displaying, and the video is missing from the front-end too, of course.
Can you check, please.. this plugin doesn't work at all with Craft CMS 3.0.0-RC10.1
If I get time I'll try to issue a PR for this as I know you're not a PHP dev to trade.
Essentially the bug is if a (I've only seen this on Vimeo so far) video URL is embedded and that video is subsequently deleted/removed the plugin errors out, pulling down the page the embed should happen on, rather than returning an empty string or whatever.
It appears to be an unhandled Embed\Exceptions\InvalidUrlException exception.
Example URL: https://vimeo.com/291962166
Hi there,
First of all: Awesome plugin!
I'm running against a little(big) problem, when using 6 embeds at once, it becomes very very slow in loading the webpage. Even when i'm trying to only show the youtube Thumbnails.
I can't lay my finger on the way this plugin gets the Thumbnail URL.
If you enter a Vimeo link that doesn't exist, Craft will throw an error, rather than fail gracefully.
Steps to reproduce:
As the title says...as it looks like it has a few outstanding issues and no updates for over 12 months.
Thanks.
I like how the new "video" field type allows for searching and preview from the CP!
How do I use it in my templates?
Hi Mike
Will the plugin communicate with the provider (eg to validate, get the thumbnail etc) on runtime or just when saving in the cp? (I guess it's a performance blocker, if it has to talk to the provider each time the frontend is rendered.) That just came to my mind, so I wanted to ask.
Best & Thanks
Urs
Hi Mike -
I set Vimeo videos to be hidden on Vimeo and only show on certain domains, including my local domain (e.g., mysite.local
). If I grab embed code directly from Vimeo and paste into template, the video plays fine, but using any videoEmbedder code results in 403 errors.
For example, putting either of these variables on the template results in the error:
{% set video = craft.videoEmbedder.getEmbedUrl(entry.video) %}
{% set thumb = craft.videoEmbedder.getVideoThumbnail(entry.video) %}
(Where entry.video = "https://player.vimeo.com/video/123456789")
Invalid url 'https://player.vimeo.com/video/123456789' (Status code 403)
(Doesn't matter if I use an entry variable or put a string in there myself).
However, if I directly paste the following into the template, it works as expected, and the video displays on mysite.local
:
<iframe src='https://player.vimeo.com/video/123456789'
frameborder='0' webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
Any idea about the difference in how the plugin is getting the video info, and just hardcoding the video info in the template?
Hello! I have the following issue: I'm able to save invalid urls, which causes exceptions in the admin and frontend, even without devMode. It results in being unable to even change the value afterwards because of the exception. I have to dig in the database itself. I would expect to get a warning when trying to save an invalid value, or get a null / undefined value in the template or something.
PS: I'm not that great with php/backend, otherwise I would've created a PR myself. Great plugin though!
If user uses a link where embedding is disabled (eg. https://www.youtube.com/watch?v=P_qRH_SkJEM) the Craft Plugin throws an unrecoverable error:
Return value of mikestecker\videoembedder\services\VideoEmbedderService::embed() must be of the type string, null returned
Since we don't always have control over what a user posts, this error should be catched and mentioned that there is no embedding allowed, or at least the null should be able to covered in the twig template.
When using a Vimeo URL, we get the following error using the getProviderName method:
Undefined property: stdClass::$providerName
Code is as follows (copied from the example in the documentation for plyr):
{% set videoUrl = 'https://vimeo.com/76979871' %}
{% set videoId = craft.videoEmbedder.getVideoId(videoUrl) %}
{% set providerName = craft.videoEmbedder.getProviderName(videoUrl) %}
{% if videoId | length %}
<div id="player" data-plyr-provider="{{ providerName | lower }}" data-plyr-embed-id="{{ videoId }}"></div>
{% endif %}
YouTube works, but Vimeo gives this error. Using Video Embedder v1.1.4.
We are using this plugin and recently we have started having the plugin throw an Internal Server Error when embedding Vimeo videos.
The logs are showing Embed\Exceptions\InvalidUrlException: Invalid url 'https://vimeo.com/294536324' (Status code 403)
but unlike Issue #7 this video has no restrictions on access or embedding.
Not at all sure why this particular video would be throwing a 403 error from the Embed service.
Any thoughts on resolution appreciated.
Craft CMS 3.3.0.1
Video Embedder 1.1.3
PHP version 7.1.31
I have a project that displays a personnel directory and each person has four videos on their page. We are seeing an odd effect when used through Brightsign's digital signage players. I'm sure the Brightsign digital signage use is not typical. However, I'm wondering if there is something in the plugin that would prevent the second video from loading or streaming the audio if the videos are played in quick succession. Is there anything we can or need to add to the code to make sure things are cleared before a video plays?
We are streaming from Vimeo URLS
http://docs.brightsign.biz/display/DOC/HTML+Best+Practices
Example:
Video A: Plays correctly
Video B: no audio but the video streams
Video C: Plays correctly
Video D: no Audio but the video streams
Thanks for your help - Great plugin!
I am trying to pull in the YouTube descriptions for the videos.
However, I am finding that these are being truncated at 156 characters.
Any ideas why or how to resolve this?
A feature request. It would be great if in the video field type there was the ability to enter the start time (minutes) and (seconds) for vides and use this on the embeds if they were set.
Similar to this: https://youtubetime.com/#
I've run into one particular YouTube video that isn't returning an embed. No errors. Doesn't output anything.
https://www.youtube.com/watch?v=XrbwUUDx-Os
I've double checked to make sure the video is public. Every other YouTube URL I've tested works fine.
The embed code seem to work fine: https://www.youtube.com/embed/XrbwUUDx-Os
This problem is happening on a local dev environment and on a staging server.
Can you think of Does Video Embedder log errors somewhere?
Just for reference, here's my template code.
{% set params = {
rel: 0
} %}
{%- set embed = craft.videoEmbedder.embed(videoUrl, params) -%}
{% if embed|length %}
<div class="video-responsive">{{ embed }}</div>
{% endif %}
PHP 7.1.26
Craft CMS 3.1.12
Video Embedder 1.1.1
This YouTube url 'https://www.youtube.com/watch?v=UAo_xJE1ta8' (or any I put in)
Embed\Exceptions\InvalidUrlException
Invalid url 'https://www.youtube.com/watch?v=UAo_xJE1ta8' (Status code 0)
if ($response->getError() === null) {
$exception = new Exceptions\InvalidUrlException(sprintf("Invalid url '%s' (Status code %s)", (string) $url, $response->getStatusCode()));
} else {
$exception = new Exceptions\InvalidUrlException($response->getError());
}
Plugin Version: 1.0.8
Craft: 3.0.1
It'd be great to be able to pull the Video's title too!
Hello, I just noticed that all my video embeds have suddenly stopped working.
I'm trying to embed this video --> https://www.youtube.com/watch?v=VvfT2wvs3h0 (which is public on YouTube)
Here's the Craft debug error:
Embed\Exceptions\InvalidUrlException: Invalid url 'https://www.youtube.com/watch?v=VvfT2wvs3h0' (Status code 429) in /srv/app/vjh-bighorn/htdocs/vendor/embed/embed/src/Embed.php:142
Stack trace:
#0 /srv/app/vjh-bighorn/htdocs/vendor/embed/embed/src/Embed.php(81): Embed\Embed::process(Object(Embed\Http\Url), Array, Object(Embed\Http\CurlDispatcher))
#1 /srv/app/vjh-bighorn/htdocs/vendor/mikestecker/craft-videoembedder/src/services/VideoEmbedderService.php(38): Embed\Embed::create(Object(Embed\Http\Url), Array)
#2 /srv/app/vjh-bighorn/htdocs/vendor/mikestecker/craft-videoembedder/src/services/VideoEmbedderService.php(216): mikestecker\videoembedder\services\VideoEmbedderService->getInfo('https://www.you...')
#3 /srv/app/vjh-bighorn/htdocs/vendor/mikestecker/craft-videoembedder/src/variables/VideoEmbedderVariable.php(47): mikestecker\videoembedder\services\VideoEmbedderService->getEmbedUrl('https://www.you...', Array)
#4 /srv/app/vjh-bighorn/htdocs/vendor/twig/twig/lib/Twig/Extension/Core.php(1619): mikestecker\videoembedder\variables\VideoEmbedderVariable->getEmbedUrl('https://www.you...')
#5 /srv/app/vjh-bighorn/htdocs/vendor/craftcms/cms/src/helpers/Template.php(73): twig_get_attribute(Object(craft\web\twig\Environment), Object(Twig_Source), Object(mikestecker\videoembedder\variables\VideoEmbedderVariable), 'getEmbedUrl', Array, 'method', false, false)
#6 /srv/app/vjh-bighorn/htdocs/storage/runtime/compiled_templates/43/436e075031d7e5673229fd1999870b2d37dc680fcafa020bff431fc5ba257e03.php(23): craft\helpers\Template::attribute(Object(craft\web\twig\Environment), Object(Twig_Source), Object(mikestecker\videoembedder\variables\VideoEmbedderVariable), 'getEmbedUrl', Array, 'method')
#7 /srv/app/vjh-bighorn/htdocs/vendor/twig/twig/lib/Twig/Template.php(390): __TwigTemplate_0f219985ff513a66ff3d8734ab47a7aa5f578ba776295f5ec4f7c1601d1bae0e->doDisplay(Array, Array)
#8 /srv/app/vjh-bighorn/htdocs/vendor/craftcms/cms/src/web/twig/Template.php(49): Twig_Template->displayWithErrorHandling(Array, Array)
#9 /srv/app/vjh-bighorn/htdocs/vendor/twig/twig/lib/Twig/Template.php(367): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#10 /srv/app/vjh-bighorn/htdocs/vendor/craftcms/cms/src/web/twig/Template.php(31): Twig_Template->display(Array, Array)
#11 /srv/app/vjh-bighorn/htdocs/storage/runtime/compiled_templates/c8/c8e45289308b00ec8c5235eb826496e06fdfb6b0711c4dbb2be3fde126278cf1.php(54): craft\web\twig\Template->display(Array)
#12 /srv/app/vjh-bighorn/htdocs/vendor/twig/twig/lib/Twig/Template.php(189): __TwigTemplate_9c2bf03b7241e24cc9b54b59ee50783347425916c52ec340ff2ab74c8441ea4a->block_content(Array, Array)
#13 /srv/app/vjh-bighorn/htdocs/storage/runtime/compiled_templates/3e/3e703181660c7199a1af705d1b3519d5f6a9acbb17c1df406fce063a85979145.php(156): Twig_Template->displayBlock('content', Array, Array)
#14 /srv/app/vjh-bighorn/htdocs/vendor/twig/twig/lib/Twig/Template.php(390): __TwigTemplate_e7cca79f9c8b45d03269112611398a5ee6b9a9cf6ce4f0dbfdf78874ba50be2d->doDisplay(Array, Array)
#15 /srv/app/vjh-bighorn/htdocs/vendor/craftcms/cms/src/web/twig/Template.php(49): Twig_Template->displayWithErrorHandling(Array, Array)
#16 /srv/app/vjh-bighorn/htdocs/vendor/twig/twig/lib/Twig/Template.php(367): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#17 /srv/app/vjh-bighorn/htdocs/vendor/craftcms/cms/src/web/twig/Template.php(31): Twig_Template->display(Array, Array)
#18 /srv/app/vjh-bighorn/htdocs/storage/runtime/compiled_templates/c8/c8e45289308b00ec8c5235eb826496e06fdfb6b0711c4dbb2be3fde126278cf1.php(29): craft\web\twig\Template->display(Array, Array)
#19 /srv/app/vjh-bighorn/htdocs/vendor/twig/twig/lib/Twig/Template.php(390): __TwigTemplate_9c2bf03b7241e24cc9b54b59ee50783347425916c52ec340ff2ab74c8441ea4a->doDisplay(Array, Array)
#20 /srv/app/vjh-bighorn/htdocs/vendor/craftcms/cms/src/web/twig/Template.php(49): Twig_Template->displayWithErrorHandling(Array, Array)
#21 /srv/app/vjh-bighorn/htdocs/vendor/twig/twig/lib/Twig/Template.php(367): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#22 /srv/app/vjh-bighorn/htdocs/vendor/craftcms/cms/src/web/twig/Template.php(31): Twig_Template->display(Array, Array)
#23 /srv/app/vjh-bighorn/htdocs/vendor/twig/twig/lib/Twig/Template.php(375): craft\web\twig\Template->display(Array)
#24 /srv/app/vjh-bighorn/htdocs/vendor/twig/twig/lib/Twig/Environment.php(289): Twig_Template->render(Array)
#25 /srv/app/vjh-bighorn/htdocs/vendor/craftcms/cms/src/web/View.php(331): Twig_Environment->render('homepage.html', Array)
#26 /srv/app/vjh-bighorn/htdocs/vendor/craftcms/cms/src/web/View.php(378): craft\web\View->renderTemplate('homepage.html', Array)
#27 /srv/app/vjh-bighorn/htdocs/vendor/craftcms/cms/src/web/Controller.php(156): craft\web\View->renderPageTemplate('homepage.html', Array)
#28 /srv/app/vjh-bighorn/htdocs/vendor/craftcms/cms/src/controllers/TemplatesController.php(78): craft\web\Controller->renderTemplate('homepage.html', Array)
#29 [internal function]: craft\controllers\TemplatesController->actionRender('homepage.html', Array)
#30 /srv/app/vjh-bighorn/htdocs/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#31 /srv/app/vjh-bighorn/htdocs/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#32 /srv/app/vjh-bighorn/htdocs/vendor/craftcms/cms/src/web/Controller.php(104): yii\base\Controller->runAction('render', Array)
#33 /srv/app/vjh-bighorn/htdocs/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('render', Array)
#34 /srv/app/vjh-bighorn/htdocs/vendor/craftcms/cms/src/web/Application.php(282): yii\base\Module->runAction('templates/rende...', Array)
#35 /srv/app/vjh-bighorn/htdocs/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('templates/rende...', Array)
#36 /srv/app/vjh-bighorn/htdocs/vendor/craftcms/cms/src/web/Application.php(271): yii\web\Application->handleRequest(Object(craft\web\Request))
#37 /srv/app/vjh-bighorn/htdocs/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#38 /srv/app/vjh-bighorn/htdocs/web/index.php(21): yii\base\Application->run()
#39 {main}
Any ideas?
I tried pasting a YouTube playlist URL in a Video Embedder field:
https://www.youtube.com/playlist?list=PL3EwcG2TRgz1HFB-2gUDjPq6p32L0ptG3
The URL preview pulls the playlist in fine and the entry saves without error but the front-end throws the following error:
PHP Notice – yii\base\ErrorException
Undefined offset: 1
1. in /vendor/mikestecker/craft-videoembedder/src/services/VideoEmbedderService.php at line 127
118119120121122123124125126127128129130131132133134135136
/**
* Parse the YouTube URL, return the video ID
* @param string $url
* @return string
*/
public function getYouTubeId($url)
{
preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $url, $match);
return $match[1];
}
/**
* Parse the Vimeo URL, return the video ID
* @param string $url
* @return string
*/
public function getVimeoId($url)
{
You get an error when a video from Vimeo has certain privacy settings enabled, which is causing the page to crash. this can be confusing for CMS users.
Could it be possible that when something like this happens, Video Embedder returns a text message for example "embed_error" or "Video cannot be displayed" instead of crashing the page?
It looks like video embedder fails to retrieve a width parameter.
I seem to find only one, on line 84 of VideoEmbedderVariable.php
Noted as it turned up as a stern (red) warning via latest PhpStorm inspections.
Here's the nature of the situation: https://github.com/kalessil/phpinspectionsea/blob/master/docs/security.md#exploiting-unserialize
Cheers...
Crashes on attempt to install.
This appears to be about a missing language config file, maybe more, but I suspect shouldn't be looking for one unless you are specifying a locale different from the English the code writes to.
Traced through to a point, but ran out of time, so just reporting.
Part of the problem may be that the proposed 'category' name doesn't match what's in translation['category']
of the method where the crash comes, I18N->getMessageSource
. In the method call, video-embedder
is passed, but the array has craft3-videoembedder
.
I tried changing the var via debugger to craft3-videoembedder
, but the crash came again, same spot, so it must get called again; and as said, ran out of time to go farther -- maybe the root of this mismatch is the problem though. It did install after the change -- but then brings down the entire CP with the trace, so watch out...removing the craft_plugins row is the way to recover.
Plugin itself, a nice idea, thank for doing it. I haven't gotten ahold of Trevor Davis to Pull Request or publish a Craft 3 port I did of his Video Embed -- looks like yours does more.
Testing on a up-to-moment dev-develop, aliased to its root of beta 23, trace attached here:
trace-video-embedder (1).txt
Looking at upgrading to Craft 4 but unclear if this plugin will be compatible.
Previously, I used getAspectRatio to return the padding-top I'd need to use to make my embed scale responsively.
So for a 16:9 video, that would be 56 (%).
That's calc'd by height/width*100.
Now (I believe since 1.1.4), this returns 1.64.
That's calc'd by width/height.
Though I suppose technically this is the aspect ratio, it's not useful in same way it was before.
So that's question 1: Should the value be w/h, or h/w?
Question 2:
I tried to do maths in the template to resolve the issue (1 / aspectRatio * 100), but because the getAspectRatio function returns a Twig_Markup object, I wasn't able to convert it to a float in order to do the maths.
My temporary solution was to add a custom variable to a different module.
return 1 / VideoEmbedder::$plugin->service->getInfo($url)->aspectRatio * 100;
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.