I'm working on a requirement where I can record the screen and load the recorded video into the quill editor.
Right now, when I'm trying to embed the video to an iframe, I'm not seeing any src value for the embeded iframe.
But when I change the src using inspect element of the browser, video is loading in the quill editor:
Below is my code.
let range = tempEditor.getSelection(true);
tempEditor.insertEmbed(range.index, 'video', tempSrc, 'user');
Here
tempSrc value is blob:http://localhost:4100/4ab588cf-7ed7-4c08-8852-6c03895ae47a
After the above statement, I can see the iframe in the editor but not the src value.
When I try to update the source as above in the inspect browser, video is playing fine
I am using following code snippet to embed an iframe (i.e. YouTube video) inside Quill.
Make sure to have the import class at the top of your class file import Quill from 'quill';
const id = '123456' //Just a unique id
const vendorLower = 'youtube';
const editorRef = this.quillEditorRef;
const range = editorRef.getSelection();
let index = 0;
if (range !== null) {
index = range.index;
} else {
index = editorRef.container.innerText.length + 1;
}
const BlockEmbed = Quill.import('blots/block/embed');
class MediaBlot extends BlockEmbed {
static create(value) {
const node = super.create();
node.setAttribute('src', 'https://www.youtube.com/embed/XXXXXXXXX');
node.setAttribute('frameborder', '0');
node.setAttribute('allow', 'accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture');
node.setAttribute('allowtransparency', true);
node.setAttribute('allowfullscreen', true);
node.setAttribute('scrolling', '0');
node.setAttribute('width', '100%');
node.setAttribute('height', '315px');
return node;
}
static value(node) {
return node.dataset.id;
}
}
MediaBlot.blotName = vendorLower;
MediaBlot.tagName = 'iframe';
Quill.register(MediaBlot);
this.quillEditorRef.insertEmbed(index + 1, vendorLower, id);
Hope someone will find this useful.
Cheers!
vibin. You said:
Here tempSrc value is
blob:http://localhost:4100/4ab588cf-7ed7-4c08-8852-6c03895ae47a
Setting a value for <iframe> src is something that should be done carefully:
The tag specifies an inline frame. An inline frame is used to
embed another document within the current HTML document.
Source
So, basically, an iframe represents cutting and pasting a portion of something on your site. For copyright reasons, many companies and websites prevent content from being displayed freely. Some, however, allow this to be done but with certain measures.
For example, YouTube allows its videos to be shared and viewed on other sites using <iframe>, but using a different URL. If you have the following URL in the browser:
https://www.youtube.com/watch?v=NihM746-Msw
The embed version, placed in <iframe>, will be as follows:
https://www.youtube.com/embed/NihM746-Msw
And the <iframe> element could have the following content:
<iframe width="560" height="315" src="https://www.youtube.com/embed/NihM746-Msw" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
Quill video format does this process automatically when a youtube video URL (from the browser) is inserted.
But there is something to watch there. Note that this way you are using a video hosted on a website, ie on the internet. If you want to display a video from your local machine (from a file), you'll need to use the HTML <video> element, not <iframe>.
How to Embed Video using HTML5 with local file
W3Schools - Video Tag
Embeds: Video, Audio and iFrame Elements
Quill's native video format does not work with the HTML video element. Therefore, you will need to create a new format that has this desired requirement.
You can find more about creating your own format at the following links:
Cloning Medium with Parchment
Quill-Examples-and-FAQ
Awesome Quill - Modules
See also the source code of the video format.
As you can see, this is not a problem with Quill, but a matter of defining the desired settings. I hope this can solve your problem and if you need more information, please add a comment to my answer and I will edit it if necessary.
Related
I have changed in theme file to display post output like below but now if am going to add any youtube URL in post text it is not showing video iframe. also, I can not use the_content() function because there is some other issue with that function.
//the_content();
$post_content .= $post->post_content;
echo $post_content;
can anyone help me to show the iframe if I add the youtube video URL in the post and display the iframe in the frontend? I know this is default WordPress functionality but it is not working.
any solution will be fine if there is a jQuery function also fine.
So, if I've understood correctly, that you can add content to a post and it shows in front end but that youtube url does not display correctly in an iframe (so it's an oembed problem) then it might make sense to think about adding the whole embed code from YouTube.
Instead of pasting https://youtu.be/TE66McLMMEw into your content area, you might paste in this instead:
<iframe width="560" height="315" src="https://www.youtube.com/embed/TE66McLMMEw" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
There are ways of using JS, grabbing a YouTube url and dynamically generating an iframe for it using the YouTube Player API (as per the video, or full docs and examples here: https://developers.google.com/youtube/iframe_api_reference ) but honestly, it seems a very complex way to solve the problem. It might be better to try and find a more robust fix that lets you use the_content().
UPDATE: if you cannot use iframe directly
We can use notes from youtube API (and a great regex from this answer here: https://stackoverflow.com/a/8260383/8228720) to generate iframe on the fly. You just need to create a div with id "player" and paste the YT url inside it.
HTML
<div id="player">https://youtube-video-link-goes-here</div>
JS
//Get video url from div
let videoUrl = document.getElementById("player").textContent;
let videoId = youtube_parser(videoUrl);
var tag = document.createElement('script');
//Parse url for video id
function youtube_parser(url){
var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/;
var match = url.match(regExp);
return (match&&match[7].length==11)? match[7] : false;
}
//Dynamically create iframe in the "player" div, adding our video id to it.
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '390',
width: '640',
videoId: videoId,
playerVars: {
'playsinline': 1
},
});
}
I am working with the example for clmtrackr here. I am trying to use an <iframe> as a source of video for the code (as opposed to using a tag, and doing this returns no results.
The example code :
<div id="container">
<video id="video" width="368" height="288" autoplay="" loop="">
<source src="./media/franck.ogv" type="video/ogg">
</video>
<canvas id="canvas" width="368" height="288"></canvas>
</div>
<script>
var videoInput = document.getElementById('video');
var ctracker = new clm.tracker();
ctracker.init(pModel);
ctracker.start(videoInput);
function positionLoop() {
requestAnimationFrame(positionLoop);
var positions = ctracker.getCurrentPosition();
// do something with the positions ...
// print the positions
var positionString = "";
if (positions) {
for (var p = 0;p < 10;p++) {
positionString += "featurepoint "+p+" : ["+positions[p][0].toFixed(2)+","+positions[p][1].toFixed(2)+"]<br/>";
}
document.getElementById('positions').innerHTML = positionString;
}
}
positionLoop();
var canvasInput = document.getElementById('canvas');
var cc = canvasInput.getContext('2d');
function drawLoop() {
requestAnimationFrame(drawLoop);
cc.clearRect(0, 0, canvasInput.width, canvasInput.height);
ctracker.draw(canvasInput);
}
drawLoop();
</script>
Has anyone attempting this yet? Any help would be much appreciated!
Thank you,
In most cases, this is not possible because of security measures built into the browser/DOM.
clmtrackr needs to access the pixels of the video file, and to do that, it needs direct access to the <video> element, which in your case is inside the iframe. In order to do that, you would need to reach into the DOM elements inside the iframe to find the video element and pass it to clmtrackr. However, it is not possible to do that unless the iframe is being served from the same domain as the outside page.
Presumably, if the iframe is coming from your own site, then you already have a way to access the source URL of the video file and can create your own element. Then you don't need the iframe. So I'm assuming you're trying to access another video hosting site, like YouTube.
Now, to be thorough, even if you could access the video element inside the iframe or if you could somehow infer the url of the video file and create your own element, clmtrackr cannot access the pixels unless that video file is, once again, coming from the same domain. This is another security measure.
The exception is if the video is served with CORS headers, as described here:
http://jbuckley.ca/2012/02/cross-origin-video/
and here:
https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image
Unfortunately, few video hosting services serve their videos with CORS headers.
i have a link google adword :
http://example.com?utm_campaign=Testcam&utm_medium=referral&utm_source=Blog&utm_content=blogers&utm_term=Test
When visitor click the link above to navigate to mysite. And then he submit a Marketo form (non Marketo form for landing page on my site).
I follow this article to create Mkto form on my site: http://community.marketo.com/MarketoResource?id=kA650000000GsPJCA0 to make sure when it submit it will get values from url parameters.
My problem on here is : Normally, this form just submit to the server to handle register. Beside that, when this form submmited, i also need it submit to Marketo for tracking. That a reason, Marketo form will be submit via iframe.
When i submit marketo form, it will be target to this iframe.
So, i need pass the url parameter into iframe to make sure when submit form, hidden fields will automatic get values from url parameters. But on this iframe, as you can see, it haven't src. I had try to add this to iframe:
$("#mktoformhidden").src = window.location.href;
but it doesn't work well.
What's the iframe src should be on here?
Thanks,
I would do something like this! Just replace "URL HERE" with your iframe url and of course update the sizing that you need in BOTH loactions.
<noscript>
<iframe src="YOUR URL HERE" width="100%" height="500" type="text/html" frameborder="0" allowTransparency="true" style="border: 0"></iframe>
</noscript>
<script type="text/javascript">
var iframeurl = 'YOUR URL HERE';
var params = window.location.search;
var thisScript = document.scripts[document.scripts.length - 1];
var iframe = document.createElement('iframe');
iframe.setAttribute('src', iframeurl + params);
iframe.setAttribute('width', '100%');
iframe.setAttribute('height', 500);
iframe.setAttribute('type', 'text/html');
iframe.setAttribute('frameborder', 0);
iframe.setAttribute('allowTransparency', 'true');
iframe.style.border = '0';
thisScript.parentElement.replaceChild(iframe, thisScript);
</script>
My guess is that an iframe is not the best solution here. The iframe can create all sorts of cross site scripting and permission based concerns.
Why not just use the new forms functionality in Marketo so you can drop the form either on a landing page or embed on your site (they come with an embed source code).
Also, the munchkin tracking code automatically grabs "query" parameters so you can use those in smart lists or reporting.
Like sahutchi said, embedding the actual Marketo form into your site could be the way to go. I opted for the iframe approach to get Marketo to automatically fill in fields based on mkt_tok. This might be possible using Marketo forms, but I wasn't able to figure it out a month or two ago.
Here's a decent overview of ways that you can integrate Marketo forms with your site: http://www.elixiter.com/marketo-landing-page-and-form-hosting-options/
If you insist on doing it the iframe way, here's my setup to pass query string params down to the embedded iframe:
This is in http://yourdomain.com/my-marketo-page:
<div class="lazy-iframe" data-src="//pages.yourdomain.com/MyMarketoPage.html" style="width: 960px; height: 1000px;">
</div>
And in some shared library (but you can have it on the same page, and simplify it a bit):
<script>
$(function() {
var $lazyIframe = $('.lazy-iframe');
if ($lazyIframe.length) {
var src = $lazyIframe.attr('data-src');
if (src) {
var $iframe = $('<iframe src="' + src + location.search + '"></iframe>');
$iframe.attr({
scrolling: 'no',
frameborder: 0
});
$lazyIframe.replaceWith($iframe);
}
}
});
</script>
Given that pages.yourdomain.com is your CNAME to your Marketo domain.
In my email, I just link to http://yourdomain.com/my-marketo-page, and Marketo will automatically add the mkt_tok for that email recipient to the end of that URL (becoming http://yourdomain.com/my-marketo-page?mkt_tok=BLAHBLAHBLAH). Then the iframe is constructed with the data-src URL and all of the parameters attached, and with no scrolling nor frameborder (up to you).
When I create an iframe player API using the onYouTubeIframeAPIReady, the link is created with the http protocol
Example:
// 2. This code loads the IFrame Player API code asynchronously.
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// 3. This function creates an <iframe> (and YouTube player)
// after the API code downloads.
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
width: '560',
height: '600',
videoId: '7j8B_r4OfAw',
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
iframe Result:
<iframe id="player" frameborder="0" allowfullscreen="1" title="YouTube video player" width="560" height="600" src="http://www.youtube.com/embed/7j8B_r4OfAw?enablejsapi=1"></iframe>
Does anyone know how to do the video to be created with the https protocol? Need to install the api on a platform.
Please, suggest!
You can specify https if you create the iframe element directly in your html, rather than using the div which gets replaced later on. You can create the iframe tag dynamically if you need to. Look at the bottom of this section, which spells out how to do it.
Beware — even if you load the player over https, the actual video stream may be served over http. That seems to cause a mixed-mode warning in Chrome, though not other browsers (in my experience last year; it may have since changed). See this official blog post, which explains that the player can be loaded over https but warns that the video still won't necessarily be served that way.
I have a page for an internal app that displays document images streamed from a document storage system using a web service. The problem I am having is that when a user does their search they may get hundreds of hits, which I have to display on one large page so they can print them all. This works fine in Firefox, but in IE it stops loading the images after a while so I get a hundred or so displayed and the rest just have the broken image symbol. Is there a setting somewhere that I can change this timeout?
If the issue is indeed a timeout, you might be able to work around it by using a "lazy load" script and adding new images to the document only after existing images have loaded.
There are a lot of ways to do this, but here's a simple example I threw together and tested. Instead of this:
<img src="image001.jpg" />
<img src="image002.jpg" />
<img src="image003.jpg" />
<img src="image004.jpg" />
<!-- Etc etc etc -->
You could do this:
<div id="imgsGoHere">
</div>
<script type="text/javascript">
function crossBrowserEventAttach(objectRef, eventName, functionRef)
{
try {
objectRef.addEventListener(eventName, functionRef, false);
}
catch(err) {
try {
objectRef.attachEvent("on" + eventName, functionRef);
}
catch(err2) {
// event attachment failed
}
}
}
function addImageToPage()
{
var newImageElement = document.createElement("img");
newImageElement.src = imageArray[nextImageNumber];
var targetElement = document.getElementById("imgsGoHere");
targetElement.appendChild(newImageElement);
nextImageNumber++;
if (nextImageNumber < imageArray.length) {
crossBrowserEventAttach(newImageElement, "load", addImageToPage);
crossBrowserEventAttach(newImageElement, "error", addImageToPage);
}
}
var nextImageNumber = 0;
var imageArray = new Array();
imageArray[imageArray.length] = "image001.jpg";
imageArray[imageArray.length] = "image002.jpg";
imageArray[imageArray.length] = "image003.jpg";
// .
// .
// .
// Snip hundreds of rows
// .
// .
// .
imageArray[imageArray.length] = "image999.jpg";
addImageToPage();
</script>
Each image is added to the page only after the previous image loads (or fails to load). If your browser is timing out, I think that will fix it.
Of course, the problem might actually not be a timeout, but rather that you're running out of memory/system resources and IE is giving up. Or there might be an IE DOM limitation like Sra said.
No final solution, but some hints...
I think the ie Dom hangs up. I,ve seen this in other cases. I needed simply to show the images and used a js which loads the image the time they came into focus, but that want work if you directly hit print I think. Can you use the new css ability to store imagedata directly instead of links. That should solve your problem. I am not quite sure but I think it is supported since ie 7
My guess is that you have to work around the IE setting, the easiest way to do it is simply not showing images that are not loaded or replacing them with a default image:
your html:
<img src="http://domain.com/image.jpg" />
your js:
$('img').load(function(){
// ... loaded
}).error(function(){
// ... not loaded, replace
$(this).attr('src','/whatever/default.jpg');
// ... not loaded, hide
$(this).hide();
});
That is a problem with microsoft. Unfortunately, this is a setting that would have to be changed on every single computer, as there is no remote way to alter it. To change it on your computer, try opening regedit and adding the RecieveTimeout DWORD with a Value of (#of minutes)*6000. Hope this helps-CodeKid1001
Edit: Sorry about that, I forgot to put in the file path:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\InternetSettings
I used something similar to laod HD pictures as a background using ASP Pages
But i used jQuery to handle the images and its loading. This is a sample for 1 image but with a bit of tweaking you can load dynamically
myImage = new Image();
$(myImage).load(function ()
{
$(this).hide(); //Stops the loading effect of large images. can be removed
$('.csBackground li').append(this); //Append image to where you need it
$(myImage).show();
}).attr('src', settings.images[0]) //I pass an array from ASP code behind so 0 can be 'i'
.error( function { checkImages(); } ) //try and relaod the image or something?
So instead of changing the timeout- just try and reload the images on error.
Otherwise i only found a solution that is client specific (HTTP Timeout)
http://support.microsoft.com/kb/813827