hmm … does that also happen when you disable the “add microdata” option (which adds the Video Schema) Adrian?
Thread Starter
Makabe
(@makabe)
Unfortunately yes, I checked all the options on and off (even “Add links below the embedded videos”).
darn … disabling will require a bit of (generic, not lyte specific) code, I’ll have a look later today/ tomorrow π
Thread Starter
Makabe
(@makabe)
Thanks! π I have one more idea.
In order for Rank Math to generate Video Schema and add it to Sitemap, there must be a direct link to YouTube video in the post content. Maybe it would be enough to add a link with a specific class under each Lyte placeholder, and then set “disable: none” to it. I have tested it now and it seems to work.
so what would be the difference with “Add links below the embedded videos” which is inside a div with class lL?
maybe adding div.lL a{disable:none;} could do the trick in Appearance -> Customize -> extra CSS?
what does disable:none do, is that required for Rankmath?
Thread Starter
Makabe
(@makabe)
so what would be the difference with βAdd links below the embedded videosβ which is inside a div with class lL?
Because then the link is like this “Watch this video on YouTube”, and is not recognized by Rank Math.
For it to work, the link should look like this https://www.youtube.*****
Thread Starter
Makabe
(@makabe)
And I meant “display:none”, not “disable:none” – sorry for that. This modification do the trick for me. Could you check if this don’t “break” anything? I tested it a few minutes ago.
In wp-youtube-lyte.php I changed this code:
$lytelinks_txt = '<div class="lL" style="max-width:100%;width:' . $lyteSettings[2] . 'px;' . $lyteSettings['pos'] . '">' . ' <a href="' . $lyteSettings['scheme'] . '://youtu.be/' . $vid . '" target="_blank">' . __( 'Watch this video on YouTube', 'wp-youtube-lyte' ) . '</a>.</div>';
to this one:
$lytelinks_txt = '<div class="lL" style="display:none!important;">' . __( '' . $lyteSettings['scheme'] . '://www.youtube.com/watch?v=' . $vid . '', 'wp-youtube-lyte' ) . '</div>';
Thread Starter
Makabe
(@makabe)
Or better this one, in that case you don’t need “Add links below the embedded videos” to be enabled:
$lytelinks_txt = '<div class="lL" style="max-width:100%;width:' . $lyteSettings[2] . 'px;' . $lyteSettings['pos'] .'"></div>';
to his one:
$lytelinks_txt = '<div class="lL" style="max-width:100%;width:' . $lyteSettings[2] . 'px;' . $lyteSettings['pos'] .'">' . '<div style="display:none!important;">' . __( '' . $lyteSettings['scheme'] . '://www.youtube.com/watch?v=' . $vid . '', 'wp-youtube-lyte' ) . '</div></div>';
always better to try to avoid changes plugin code, as every update will override your changes.
that being said, below code snippet hooks into LYTE’s API to add a hidden span with the link, give that a try maybe?
add_filter( 'lyte_match_postparse_template',
function( $lyte_template, $templateType, $yt_resp_array ) {
$vid_thumb_rexepped = preg_match( '#ytimg.com\/vi\/([a-zA-Z0-9\-\_]{11})\/#', $yt_resp_array['thumbUrl'], $matches );
$vid_link = '<span style="display:none">https://www.youtube.com/watch?v='. $matches[1] . '</span>';
return $lyte_template . $vid_link;
},
10,
3
);
Thread Starter
Makabe
(@makabe)
Yes, it works perfectly, thank you! π