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).
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
};
}
}
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.
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
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.
in that case it seems like Elementor + LYTE + AMP don’t mix, bummer ..