• danescobar

    (@danescobar)


    Hello, I include videos in my website inserting a shortcode widget with Elementor and then using a lyte id. This makes that my AMPs show just a link to the YouTube video instead of a mini player like the mobile or desktop version.

    Is there a way for Lyte to insert a player or some workaround with a PHP function or CSS code?

    Also I’d like to know if you can confirm this statement from Pagepipe website:

    LYTE by default uses WordPress “the_content”-filter. Pagebuilders (Elementor) don’t apply that filter to their content. So LYTE plugin doesn’t work on Elementor. Neither do other lazy load for video plugins.

    Thanks for your attention.

    • This topic was modified 7 years ago by danescobar. Reason: adding info from pagepipe
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    LYTE uses JS to render the player, which in AMP-context is very to be restricted. As such (and per the code), so LYTE simply bails on AMP. You might need to configure your AMP-plugin (if possible) to handle YT-links in that case?

    LYTE can work on pagebuilders by either using the LYTE-widget or the LYTE shortcode (which one depends on the pagebuilder).

    Thread Starter danescobar

    (@danescobar)

    Thanks for your answer. Official AMP plugin is very limited in that regard, I even need to add Glue for Yoast SEO to add some customization. I don’t see how I could configure it to handle YouTube links besides asking the devs for support as I’m doing with you.

    I have very limited PHP knowledge but maybe this php/pseudocode could be a primitive start and something you or official AMP devs would consider adding to your plugin after you manage to make it work? I think it may lazy load videos in AMP through (amp-youtube-0.1.js). At least it would give them support instead of showing a link.

    Hope I can contribute a bit to the community and I would be very appreciated if you can take the time to refine the code and consider my suggestion. At the very least you would help me make the code work and implement it to my website with a snippet:

    /* Detecting if page is AMP */
    $dom = new DOMDocument();
    @$dom->loadHTML($html);
    
    $nodes = $dom->getElementsByTagName('link');
    foreach ($nodes as $node)
    {
    	if ($node->getAttribute('rel') === 'amphtml')
        {
        	echo($node->getAttribute('href'));
            /* amp page found, now insert code in head */
            $vid_var = function(truncate YouTube link in page);
            add_action('wp_head', 'add_ytcode');
    			add_ytcode($vid_var){
    			?><script async custom-element="amp-youtube" src="https://cdn.ampproject.org/v0/amp-youtube-0.1.js">
            		<amp-youtube width="480"
    			  		height="270"
      					layout="responsive"
      					data-videoid="$vid_var">
    				</amp-youtube>
            	</script>
    			<?php
            };
        }
    }
    Plugin Author Optimizing Matters

    (@optimizingmatters)

    Just checked on my own little blog, as you can see on https://blog.futtta.be/2019/04/12/music-from-our-tube-coming-home-with-swindle-kojey-radical/?amp the AMP plugin I’m using is showing the YT video using amp-youtube-0.1.js. I’m using https://ww.wp.xz.cn/plugins/amp/ in classic/ reader mode, no special config/ coding done.

    Thread Starter danescobar

    (@danescobar)

    Hmm then it may be Elementor who’s interfering with its normal behavior. All my videos are inserted through an Elem. shortcode widget and all present this error. How’s your video inserted in the page you mention?

    I will test this using other ways to insert it in Elementor (httpv in a text widget and using a Lyte widget to see if it works). I’ll update this thread after doing it.

    Thanks for your support @optimizingmatters

    Thread Starter danescobar

    (@danescobar)

    Done checking and none of the three methods work with Elementor or, in case Elem. isn’t the culprit, another plugin is causing the incompatibility.

    Shortcode with lyte id shows only the link, lyte widget shows a thumbnail but redirects to YouTube and httpv in text doesn’t do anything. Here you can see the behavior of the three methods.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    in that case it seems like Elementor + LYTE + AMP don’t mix, bummer ..

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Video player in AMP’ is closed to new replies.