I use infinite scrolling together with a third party plugin "HideYT", with which related YouTube videos and other YouTube stuff (e.g. video titel) can be hidden. The third party plugin helps to achieve the same goals, that could be achieved through rel=0 and showinfo=0 in the past.
Recently the plugin switched from this code: hidden link
to this code: hidden link
With the new code (hidden link) there is the issue, that as soon as the infinite scrolling kicks in the YouTube videos from the "previous" page disappear and there is a white space instead. I investigated the problem together wíth the plugin creator and that is what he figured out:
------------------------
"As far as where the issue is in the code, it's not really as much an issue with specific lines of the code as it is with the way the whole script is designed to only be run once, then expects the iframes to stay in place after everything is set up (the infinite scroll plugin that you have installed clears out the iframes, removing the HideYT code from them). The main entry point of the application logic is in the "updatePlayers" function, which is called periodically on a timer to detect and convert new YouTube iframes to HideYT iframes using the "initPlayer" function. The HideYT code converts the YouTube iframe into its own HideYT iframe that has the YouTube iframe nested one layer deeper. You can see the nested iframes in a web browser's element inspector.
Regards,
-Max"
------------------------
He says he can't do anything about it.
Is there a way with which I can prevent, that the Toolset infinite scrolling clears out the iframe?
Thank you for getting in touch. I suspect that this is occurring because the plugin you are using is dynamically adding the iframes using Javascript.
If that is the case whenever the AJAX pagination triggers then the id's of the posts being displayed are changed because the data is being dynamically loaded.
In a case like this we will need a callback function to trigger the code in the plugin again. If the Author has written a function that can be called back then you can add it in the Callback function below and trigger your code again.
jQuery( document ).on( 'js_event_wpv_pagination_completed', function( event, data ) {
/**
* data.view_unique_id (string) The View unique ID hash
* data.effect (string) The View AJAX pagination effect
* data.speed (integer) The View AJAX pagination speed in miliseconds
* data.layout (object) The jQuery object for the View layout wrapper
*/
});
Unfortunately most of the HideYT code is designed to only run once, when the page is initially loaded, so it would require a rewrite of large parts of HideYT to be able to integrate a JavaScript callback like that. Currently the plugin creator is not interested to rewrite the code and integrate the JavaScript callback. He offered me a refund instead.
The interesting thing is, that the problem only occurs on the "so to speak previous page", whereas the newly loaded posts are not affected..
If you think, that there is no other option than using a callback, then I will accept, that that's a dead end at the moment 😉
Thats not welcoming news at all. Unfortunately the only other workaround I can think of is to not use AJAX pagination which in your case may not be an option.
I would recommend the developer rethink this approach as it would mean that AJAX pagination from any plugin may end up breaking the functionality as it did here.
At this point not much we can do here from our side.