Giter VIP home page Giter VIP logo

mpratt / embera Goto Github PK

View Code? Open in Web Editor NEW
330.0 19.0 57.0 1.41 MB

A Oembed consumer library, that gives you information about urls. It helps you replace urls to youtube or vimeo for example, with their html embed code. It has advanced features like offline support, responsive embeds and caching support.

License: MIT License

PHP 99.53% Smarty 0.47%
oembed embed-videos youtube twitter vimeo html-embeddable php instagram facebook dailymotion

embera's People

Contributors

andrewminion-luminfire avatar annieyo avatar azeos avatar billtomczak avatar brusch avatar danielecolangelo avatar deenison avatar dotzero avatar elvismdev avatar florisderks avatar fsutawanir avatar godismyjudge95 avatar gromnan avatar j0k3r avatar kjschubert avatar libertykite avatar mattleff avatar matzeeable avatar mpratt avatar n3t avatar payter avatar robbytaylor avatar silentworks avatar simshaun avatar sovetski avatar vkhramtsov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

embera's Issues

Twitter embeds don't work on production

Thanks for such a great package.

I am using Laravel, locally using Laravel Sail and in production using a Laravel Forge provisioned Digital Ocean droplet.

I am running this code:

Illuminate\Support\Facades\Artisan::command('embed', function () {
    $embera = new \Embera\Embera();

    // $testUrl = 'https://www.youtube.com/watch?v=J---aiyznGQ'; // πŸ‘Œ
    // $testUrl = 'https://vimeo.com/374131624'; // πŸ‘Œ
    // $testUrl = 'https://twitter.com/KYVENetwork/status/1655919857685221376?s=20'; // πŸ’©
    $testUrl = 'https://twitter.com/Interior/status/507185938620219395'; // πŸ’©

    $embedUrlData = $embera->getUrlData($testUrl);

    dump($embedUrlData);
});

It seems that Twitter embeds return an empty array every time on production, but work locally.

Does you have any suggestions why that could be?

Thanks again.

E_WARNING: curl_setopt_array(): CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set

The curl option CURLOPT_FOLLOWLOCATION, causes an E_WARNING:

E_WARNING: curl_setopt_array(): CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set

when open_basedir or safe_mode is set and enabled. Therefore this check should be made and the curl function changed. Patch is below (Sorry for not creating a fork - quite busy today)

    /**
     * Uses Curl to fetch data from an url
     *
     * @param string $url
     * @return string
     *
     * @throws Exception when the returned status code is not 200 or no data was found
     */
    protected function curl($url)
    {
        $defaultOptions = array(
            CURLOPT_URL => $url,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_ENCODING => '',
            CURLOPT_USERAGENT => 'Mozilla/5.0 PHP/Embera',
            CURLOPT_HEADER => false,
            CURLOPT_RETURNTRANSFER => 1,
        );

        $handler = curl_init();

        $use_redirect = false;
        if(
             (ini_get('safe_mode') || ini_get('open_basedir'))
          && (
                ((($is_options = isset($this->config['curl'][CURLOPT_FOLLOWLOCATION])) === true && $this->config['curl'][CURLOPT_FOLLOWLOCATION] === true))
             || (($is_defaults = isset($defaultOptions[CURLOPT_FOLLOWLOCATION])) === true && $defaultOptions[CURLOPT_FOLLOWLOCATION] === true)
            )
        )
        {
            $use_redirect = true;

            if($is_options === true)
                unset($this->config['curl'][CURLOPT_FOLLOWLOCATION]);
            if($is_defaults === true)
                unset($defaultOptions[CURLOPT_FOLLOWLOCATION]);
        }

        curl_setopt_array($handler, $defaultOptions);

        if (!empty($this->config['curl']))
        {
            foreach ($this->config['curl'] as $key => $value)
                curl_setopt($handler, $key, $value);
        }

        if($use_redirect === true)
        {
            return $this->curl_redirect($url, $handler);
        }

        return $this->curl_follow($url, $handler);
    }

    protected function curl_follow($url, $handler)
    {
        $data = curl_exec($handler);
        $status = curl_getinfo($handler, CURLINFO_HTTP_CODE);
        curl_close($handler);

        if (empty($data) || !in_array($status, array('200')))
            throw new \Exception($status . ': Invalid response for ' . $url);

        return $data;
    }

    protected function curl_redirect($url, $handler)
    {
        curl_setopt($handler, CURLOPT_HEADER, true);

        $data = curl_exec($handler);

        $status = curl_getinfo($handler, CURLINFO_HTTP_CODE);
        if($status == 301 || $status == 302)
        {
            list($header) = explode("\r\n\r\n", $data, 2);

            $matches = array();
            preg_match("/(Location:|URI:)[^\n]*/", $header, $matches);
            $url = trim(str_replace($matches[1], "", $matches[0]));

            $url_parsed = parse_url($url);
            if(isset($url_parsed))
            {
                curl_setopt($handler, CURLOPT_URL, $url);
                return $this->curl_redirect($url, $handler);
            }
        }

        curl_close($handler);

        list(, $body) = explode("\r\n\r\n", $data, 2);

        if (empty($body) || !in_array($status, array('200')))
            throw new \Exception($status . ': Invalid response for ' . $url);

        return $body;
    }    

Adding custom query string parameters to a service

Hi,

        $config = array(
            'custom_params' => array(
                'Youtube' => array('showinfo' => 0)
            )
        );

        $embera = new Embera($config);

If I use 'Youtube' or 'youtube' it doesn't work, I can't add custom query params to a service.
The returned iframe doesn't contain such param.

Did I miss something?

Thank you for the great work.

J.

Adding my own endpoints

It would be great if I could add in my oembed endpoints, I realised you have the services as protected property and findServices as protected method so there is no way to extend this.

Thanks for this library as it has solved 90% of my problems.

Allowing CKEditor5 code

I am using CKEditor 5 which outputs embedded data such as this:

<p>This is a some text</p>
<figure class="media">
    <oembed url="https://www.youtube.com/watch?v=NyEq7unEv5I"></oembed>
</figure>
<p>Above and below some video</p>

Is there a way using this library to output the iFrame, when I try running this through autoEmbed I get the following:

<p>This is a some text</p>
<figure class="media"><oembed url="<iframe width="480" height="270" src="https://www.youtube.com/embed/NyEq7unEv5I?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>"></oembed></figure>
<p>Above and below some video</p>

It looks like as it's within the oembed url= it isn't displaying on the site

How about dropping support php version prior to 7.2?

Hi!
Currently only php version 7.2, 7.3 and 7.4 officially supported, also you are testing only these versions. Also for tests you are using phpunit version, which require at least php version 7.2.
What do you think about dropping support of php versions prior 7.2 in composer.json? I can create PR for this.

The New YouTube Desktop Design is not Supported.

YouTube Just rolled out a new desktop design which is not supported by the Embera Library.

I am currently using the below code the get the Title, Description and Embed Code pending the time the issue is resolved

<?php
	$link = isset($_GET['link']) ? $_GET['link'] : 'https://www.youtube.com/watch?v=myEv3Qr3Efo';
	$link_details = parse_url($link);
	$scheme = isset($link_details['scheme']) ? $link_details['scheme'].'://' : '';
	$host = isset($link_details['host']) ? $link_details['host'] : '';
	$query = isset($link_details['query']) ? $link_details['query'] : '';
	$id = '';
	if(preg_match('/youtube\.com$/i', $host)) {
		parse_str($query, $params);
		$id = isset($params['v']) ? $params['v'] : $id;
	} elseif(preg_match('/youtu\.be$/i', $host)) {
		$link = preg_replace('/www\.youtu\.be$/i', 'youtu.be', $link);
		$host = 'www.youtube.com';
		$id = trim($path, '/');
	}
	$url = $scheme.$host.'/embed/'.$id;
	$code = '<iframe frameborder="0" src="'.$url.'" allowfullscreen=""></iframe>';
	$title = '';
	$description = '';
	if(ini_get('allow_url_fopen')) {
		$source = file_get_contents($link);
		$source = mb_convert_encoding($source, 'utf-8', mb_detect_encoding($source));
		$source = mb_convert_encoding($source, 'html-entities', 'utf-8');
		$doc = new DOMDocument();
		@$doc->loadHTML($source);
		$nodes = $doc->getElementsByTagName('title');
		$title = $nodes->item(0)->nodeValue;
		$metas = $doc->getElementsByTagName('meta');
		$x = 0;
		for ($i = 0; $i < $metas->length; $i++) {
			$meta = $metas->item($i);
			if($meta->getAttribute('name') == 'description') {
				$description = $meta->getAttribute('content');
				break;
			}
		}
	}
	header('Content-Type: text/plain');
	print("CODE:\n");
	print($code."\n");
	print("\nTITLE:\n");
	print($title."\n");
	print("\nDESCRIPTION:\n");
	print($description);
	exit;

Regards.

Allow hidden vi

When embedding from Vimeo the regular expression on the provider file doesn't allow hidden videos with their hash.

The regular expression should be changed to:

return (preg_match('~/(?:[0-9]{5,12}/?[\w\d]*)$~i', $this->url)); //modified to capture hash on hidden videos

Vimeo private video links

Vimeo's oEmbed API supports private links, however the Vimeo provider does not have a regex for these so they don't work with Embera.

For example, this link https://vimeo.com/585333437/4c8cc133a5 works via oEmbed:
https://vimeo.com/api/oembed.json?url=https://vimeo.com/585333437/4c8cc133a5

I added this to Embera as a test and it worked, although I'm not sure exactly what the rules are for the hash on the end, I guess it may not always be 10 chars.

            preg_match('~vimeo\.com/(?:[0-9]{5,})/(?:[0-9a-z]{10})$~i', (string) $url) ||

Broken/Unsupported Providers

This is more a heads up than anything else.

  • Hulu - no longer supports oembed
  • Meetup - not clear but it looks like they don't support oembed anymore
  • Sketchfab - we couldn't figure out how to get it working. The validateUrl method doesn't seem to be correct.
  • Twitch - oembed support is unclear. We couldn't figure out how to get it to work
  • Wordpress - we couldn't understand how or what this would be used for. Unable to find a sample url that works

We're just ignoring these in our implementation, so it's not a big deal.

Embedding playbuzz items

Hi,

Was wondering how could we go about adding Playbuzz to Embera? I can provide you with anything you need - the oEmbed endpoint and whatever you require :)

Thanks!

Argument 2 passed to Embera\Http\OembedClient::__construct() must be an instance of Embera\Http\HttpClient, instance of Embera\Http\HttpClientCache given

Following the guidelines at https://github.com/mpratt/Embera/blob/master/doc/06-caching.md I configured my temporary directory but I couldn't request anything due to the error: "Argument 2 passed to Embera\Http\OembedClient::__construct() must be an instance of Embera\Http\HttpClient, instance of Embera\Http\HttpClientCache given".

The problem rises from the fact that HttpClientCache correctly implements HttpClientInterface but OEmbedClient's constructor checks on HttpClient and not its interface.

Wikipedia provider

Hello will be great if there is added by defoult a wikipedia provider

Github Gists

First of all, thanks for this lib. Its awesome! :)

But I think I found a minor limitation when it comes to Github Gists urls.
The problem is that the current version of Embera doesn't support all gists url variations, I'm afraid of.

If we check both the test file TestServiceGithubGist.php and the service provider code GithubGist.php, its clear that the support covers the following url pattern:

github\.com\/(?:[^\/]+)\/([\d]+)\/?

which basically translates to:

github.com/<GIST-OWNER-USERNAME>/<GIST-ID>

The issue comes when we have a gist whose its GIST-ID consist in an alpha-numeric value, not only numeric values, defined by the [\d]+ rule.

I.e, where both cases should be considered as valid ("good"):

  • good url: https://gist.github.com/mpratt/5671743
  • bad url: https://gist.github.com/deenison/1924c23f27fe27fe7da68375d71c5ae8

So, wouldn't be better if we change that numeric rule to [a-z0-9]+ (already using case-insensitive flag)?

Regards.

Ignore or modify links

Hi, I guess oEmbed was invented to enhance user generated content. The big problem I have is that I'm getting a mix of plaintext and html. Plaintext is fine, but for example <a href="http://youtube.com/***">http://youtube.com/***</a> is getting messed up when parsed through Embara.

There are several solutions I thought off:

  • Strip all links from my content (bad, there are links that are linking to non oembed sites)
  • Strip links from oEmbed sites (a bit bad, I had to maintain another list of regex's)
  • Embara could ignore links wrapped in html (in my opionion the best solution)
  • Embara could remove html from oEmbed site links and replace them with am embed code (good, but sometimes it could be important to keep a link as a link)

Did you encountered such a problem and what did you do?

Greets, SΓΆren

get extra info from url

How can I get extra parameters from an url, like:

  • description
  • thumbnailUrl
  • thumbnailWidth
  • thumbnailHeight

Thanks!

Bug: custom_params doesn't work for non-default providers

$config = array(
    'custom_params' => array(
        'CustomProvider' => array('align' => 'center', 'hide_media' => 1)
    )
);

$embera = new \Embera\Embera($config);

$embera->addProvider('custom.com', 'ExampleLib\CustomProvider);

$response = $embera->getUrlInfo('http://custom.com/foo/bar'); // does not pass custom_params

Doesn't work, because Providers::addProvider() is fired after Providers::extractCustomParams().

Facebook is problematic

For posts, the height is too big and the result isn't responsive.

For pages, a url like https://www.facebook.com/<USER> always seems to return the dreaded 'This Facebook post is no longer available'

Videos seem to be okay and responsive, if not necessarily what might be desired.

We've spent quite bit of time trying to figure out how to fix the height issues in posts with little success. The one thing that seems to make everything work better was to skip the modifyResponse() method entirely and unset the provider name. We have a subclass to do this:

public function modifyResponse(array $response = [])
{
    unset($response['embera_provider_name']);

    return $response;
}

Pages - now are accessible, if unresponsive and the height is correct
Posts - no change other than the height problem is fixed, still not responsive
Videos - The video is now fully embedded without the FB user/share links and still responsive

I'm having trouble wrapping my brain around what the intent behind FaceBook::modifyResponse() code is. I assume the idea is to make the non-responsive response responsive. But it doesn't do that for posts and makes pages not work.

For now our lame patch does what we need it to do, but it doesn't strike me as a particularly good fix.

I'd be happy to work on a patch, but I'm unclear how to approach this.

iFrame `frameborder` attribute is deprecated in HTLM5

Hi,

First thank for your amazing lib :)

After running a W3C test on the Embera HTML output , I've noticed that the frameborder attribute was deprecated and should be removed: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#frameborder

The value 1 (the default) draws a border around this frame. The value 0 removes the border around this frame, but you should instead use the CSS property border to control <iframe> borders.

For now I'm adding a filter to fix that:

$embera->addFilter(static function ($response) use ($loading) {
            if (!empty($response['html'])) {
                $response['html'] = str_replace('frameborder="0"', "", $response['html']);
            }

            return $response;
});

But it would be to release a new Embera for everyone :)

Spotify artist link not working

When using Spotify artists links the library returns an empty result. The link https://open.spotify.com/intl-de/artist/5eAWCfyUhZtHHtBdNk56l1?si=i0-JP01CRz-X4n_pQOZpKA for example doesn't work. The link is coming directly from Spotify, when you go to an artist page and click Share -> Copy link to artist.

The reason is that the Spotify Provider doesn't support the url parts intl-xx and artist as you can see in the validateUrl function.

Embeds in <pre> tags

Embera does not take into consideration when URLs are posted within <pre><code> tags. Since these tags (code blocks) are normally used for demonstrating code, I don't want a URL that happens to be a provider to be parsed within these code blocks.

I believe this should be a config option in Embera, or at the very least how would I be able to do this myself?

(OLD) Road to Embera 2.0

I am starting to think about version 2.0 of this library. There are some areas of improvement and perhaps I might need to introduce some changes to the API that might break compatibility.

As of now, the main points that I think are very important in order to release a 2.0 version are:

  • Reduce Class complexity.
  • Change the way the library handles custom Oembed Providers. In other words, make it simpler!
  • Expose an API that allows the user to modify the Oembed response directly.
  • Use Interfaces so that developers can change parts of the Library via dependency injection.
  • I am not happy with the configuration array, lets simplify it a bit
  • Lets get away from the Formatter Class and find another way to use "templates"

Other stuff I've been thinking about that I'm not sure that should be implemented on Embera are:

  • A simple caching system (probably file based) for urls
  • A global (or per Provider) way to handle https embeds
  • Normalize the oembed responses (some providers reply with thumbnailWidth others with thumbnal_width πŸ˜’ )
  • Add Embedly/NoEmbed/Iframely providers
  • Look into responsive embeds and the possibility to implement them on some providers

We all know that PHP 5.3 is deprecated now (since August 2014), but I still plan on supporting it. Yeah, I know how it feels when you're stuck on a shitty environment without ways to upgrade.. I feel your pain too..

I'm going to keep fixing bugs and adding providers to version 1.x.x. Version 2.0 should be available somewhere in february 2015.

I will make a 2.0 branch available over the weekend in order to start playing.

Feel free to comment and share your ideas/thoughts for this library.

  • Edit: grammar :(

Added Wordwall provider

Hi,
First of all, thanks for this package.

I've just added wordwall.net provider to our platform. Are you accepting PR?

Documentation

/**
 * Wordwall Provider
 * @link https://wordwall.net/
 * @link https://wordwall.net/about/oembed
 */
class Wordwall extends ProviderAdapter implements ProviderInterface
{
    /** inline {@inheritdoc} */
    protected $endpoint = 'https://wordwall.net/api/oembed/?format=json';

    /** inline {@inheritdoc} */
    protected static $hosts = [
        'wordwall.net'
    ];

    /** inline {@inheritdoc} */
    protected $httpsSupport = true;

    /** inline {@inheritdoc} */
    public function validateUrl(Url $url)
    {
        return (bool) (preg_match('~wordwall\.net/(?:[^/]+/)?(?:resource|play)/.*+~i', (string) $url));
    }

    /** inline {@inheritdoc} */
    public function normalizeUrl(Url $url)
    {
        $url->convertToHttps();
        $url->removeQueryString();

        return $url;
    }

}

Soundcloud not working

I am not sure if you tested this, but Soundcloud oEmbed is not working, I am unable to find the issue but If I do before you I will send in a PR.

Playbuzz implementation is incomplete

It looks like the Playbuzz service was going to be added but wasn't completed. Looks like it was copied from BlipTV service but not fully updated

Facebook embed bug

When embedding Facebook with a formatter, you get 'Array to string conversion'.

To reproduce, use the following:

$text = 'https://www.facebook.com/adam.j.mccann/posts/10156943904420037?pnref=story';
$embera = new \Embera\Embera();

$formatter = new \Embera\Formatter($embera);
$formatter->setTemplate('{html}');

return $formatter->transform($text);

This is caused by the provider file here (Embera\Providers\Facebook, line 162)

// Backup the real response
$response['raw']['html'] = $response['html'];

There may be other providers that have multi-dimensional arrays on the response that would also cause this issue.

New Dailymotion url support

Hi,
it seems only the old Dailymotion url types (dailymotion.com/username/video/id) are embedded.
The new url's (dailymotion.com/video/id_title) aren't recognized.

I changed the validateUrl regex to
~dailymotion\.com/(?:[^/]*)/?video/(?:[^/]+)/?~i
That got it working for both url types.
Maybe you could have a look at this issue before the next release.

Thanks!

Add an option for iframe lazyloading

Support for native iframe lazy loading is now pretty good : https://caniuse.com/loading-lazy-attr

This can be handled with a filter:

$embera->addFilter(static function ($response) use ($loading) {
            if (!empty($response['html'])) {
                $response['html'] = str_replace('<iframe', "<iframe loading=\"{$loading}\"", $response['html']);
            }

            return $response;
});

But IMO, it would be nicer to add a loading option to set this attribute when using autoEmbed().
Everyone should enjoy the joy of iframe lazyloading 😸

youtube rel=0 ?

Am I correct in thinking that there is no support in Embera for the rel=0 youtube parameter that limits related videos to the channel that produced it?

Spotify Embed

I'm trying to embed from Spotify and I don't think it's working correctly. Could you check it out?
Thank you!

Custom Provider Parameters

re: https://github.com/mpratt/Embera/blob/master/doc/07-advanced-usage.md#passing-custom-parameters-to-provider

This doesn't work for Facebook/Instagram access_tokens. $config['instagram_access_token'] will not be seen by the Instagram provider. If I pass $config['access_token'] then both Facebook and Instagram work fine.

It's unclear to me how best to fix this. access_token does need to be in $this->config but using instagram_access_token means it only appears in getParams() and the Instagram provider uses the legacy endpoint.

I'd be happy to create a PR with a proposed fix, but perhaps you would more quickly know the best way to deal with this.

Bug: autoEmbed replacing embed URLs incorrectly

Embera::autoEmbed() does a str_replace on the embed URLs with the replacement HTML, but this is prone to a bug.

Str_replace here replaces a embed URLs containing text that exactly matches URLs later on in the replacement text, so the URLs later on are truncated, and the net result is one or more duplicated embed objects with superfluous text.

I have created an example test case to illustrate the issue:
https://gist.github.com/assembledadam/8c25c24956cc496a9203

Not recognising Twitter or Flickr URLs (v1.9.2)

I just found this (wonderful) library, and I am trying to allow for detection and replacement of Twitter and Flickr URLs through oEmbed.

My Code:

`require_once( 'inc/Embera/Autoload.php' );

$embera = new \Embera\Embera();

$text = 'http://vimeo.com/groups/shortfilms/videos/66185763
http://www.flickr.com/photos/bees/8597283706/in/photostream
https://twitter.com/Interior/status/507185938620219395
http://youtube.com/watch?v=J---aiyznGQ';

echo $embera->autoEmbed( $text );`

My Output:
image

Error is found regardless of whether the Twitter URL is prefixed with https or http.

Any help would be greatly appreciated.

How do I change embed to use https?

Hi,
I am trying to use this on a secure server, is it possible to change embed links to https? I see a function for it, just not sure how to use it.

Thanks,
Amir

Support custom request headers

Hello!

I was wondering if it is possible to send custom headers when using the $embera->getUrlData()?

I'm having an issue with private videos from Vimeo, the endpoint returns a different response for this kind of videos and the thumbnail fields are not included.

According to the Vimeo docs a Referer header must be sent with the whitelisted domain so it can return the private metadata which includes the thumbnail data.

Thank you!

Specify provider(s)

Thanks for this awesome library,
The issue is, what if i want to specify specifec provider(s) for my request, so it will return if this url is from this provider or not before getting the data and then checking the provider name and stuff ?
is this possible ?, or I need to do the filter for the url before using the embera class?

Thanks

Defer loading iframes and remove obsolete iframe's tags

Hiyo.

First wanna thank you for awesome script. Works excellent!

The one and only problem I have is how to defer loading generated iframes. I have a script:

<script>
function init() {
var vidDefer = document.getElementsByTagName('iframe');
for (var i=0; i<vidDefer.length; i++) {
if(vidDefer[i].getAttribute('data-src')) {
vidDefer[i].setAttribute('src',vidDefer[i].getAttribute('data-src'));
} } }
window.onload = init;
</script>

It should defer loading generated iframes, but iframe src should be empty and then embed source should be placed in 'data-src':

For example:

<iframe width="1280" height="720" src="" data-src="https://www.youtube.com/embed/UYTpYxJ9K4Y?list=PL4oON97FJp1EA9bGxoG5l2V2vizelKLC2" frameborder="0" allowfullscreen></iframe>

instead of:

<iframe width="1280" height="720" src="https://www.youtube.com/embed/UYTpYxJ9K4Y?list=PL4oON97FJp1EA9bGxoG5l2V2vizelKLC2" frameborder="0" allowfullscreen></iframe>

Is any possible to change a code in this way or maybe is any other solution to defer loading generated iframes?

I have also another question: is any chance to automaticly remove depreciated "frameborder" from iframe tags?

Dariusz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.