Skip Navigation

[Resolved] iframe youtube change to thumbnail

This support ticket is created 4 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 11 replies, has 2 voices.

Last updated by ibrahimM 4 years ago.

Assisted by: Shane.

Author
Posts
#1839223
Picuture 2.JPG
Picture 6.JPG
Picture 5.JPG
Picture 4.JPG
Picture 3.JPG
Picture 1.JPG

I am Ibrahim;

Tell us what you are trying to do?
change any iframe youtube video to thumbnail image

Is there any documentation that you are following?
wp rocket have this function to change iframe youtube video to thumbnail image

Is there a similar example that we can see?
No

What is the link to your site?
etuisyen.my

Previously our website (etuisyen.my) are very slow (picture 1)
This is mainly due to 16.9MiB of JavaScript is parsed during initial page load, as shown in picture below (picture 2)
To resolve this issue , we install wp rocket and enable iframe image and video (picture 3)
The results in gtmetrix after enable is very good (picture 4)

However got issue:
1) Got Gap in View (etuisyen.my page) (Picture 5)
2) Next pagination not change to thumpnail instead still using video iframe(Picture 6)

Suggestion:
Please advise on how to directly change the iframe youtube to thumpnail inside the toolset , so that no need for us to switch on the wp rocket.

Thank You

#1840495

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ibrahim,

Thank you for getting in touch.

Unfortunately given that you are using an Iframe to display the youtube videos you won't be able to automatically generate a thumbnail unless there is some form of custom code involved.

The custom code will need to do the work of getting a thumbnail from the iframe. Secondly you can try using your view without the AJAX refresh so that it reloads the page entirely which should cause the pagination to work correctly with the plugin you've installed.

Thanks,
Shane

#1840709
lazy code added after switch on wp rocket.JPG
On wp rocket iframe.JPG

Yes... Thats what I am thinking..

after switch on the wp rocket, 1 line of code was added , with is:

<img loading="lazy" alt="" width="480" height="360" src="hidden link" class="lazyloaded" data-ll-status="loaded">

The question is.. how we want to do this;

Can you help us on this, this will surely improve our website speed.

Thank You

#1840727

How we want to add this code to our views page.

Thank You

#1841401

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ibrahim,

It seems the WP rocket plugin replaces the iframes using some form of Javascript. Unless there is a specific javascript function that can be ran manually to replace the iframes with thumbnails then I would recommend using the AJAX refresh for your view.

Disabling the AJAX refresh should allow your results to display properly when paginating.

Finally if you want the AJAX refresh you will need to get in touch with the WP Rocket team and ask them about a function that can manually trigger the replacing of iframes with thumbnail.

Thanks,
Shane

#1843259

I am searching for it.

It's call lazyload. Toolset have this function?

#1843533

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ibrahim,

We have functions to Lazyload other Javascripts given that we know what that function to be called is.

What we provide is the Lazyload function for our Views AJAX actions and you can add the functions you want to lazyload within that function.

So unless we know what the function is that will generate the iframe thumbnail then we won't be able to lazyload it.

Thanks,
Shane

#1844775

Hi;

Actually its already resolved, it just that I cannot switch on ajax.

Mind if telling me how to do lazyload + ajax function.

Thank You

#1846135

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ibrahim,

Mind if telling me how to do lazyload + ajax function.

As mentioned previously you are using the WP Rocket plugin to convert the iframes to thumbnails.

I suspect this uses Javascript on the initial page load. When you perform an AJAX action the content refreshes without reloading the page so the javascript isn't ran again.

In order to do this you will need to lazyload the function from the WP Rocket plugin that is responsible for this. We have callback functions for our AJAX action that you can add the WP Rocket function into but unless we know what the function is then we can't reinitialise it.

For the Pagination complete ajax action you will use.

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
	*/
	
/*WP ROCKET FUNCTION GOES HERE*/
});

and for the Search complete ajax action

jQuery( document ).on( 'js_event_wpv_parametric_search_results_updated', function( event, data ) {
	/**
	* data.view_unique_id (string) The View unique ID hash
	* data.layout (object) The jQuery object for the View layout wrapper
	*/
	
/*WP ROCKET FUNCTION GOES HERE*/

});

Once you know the function you can add it to both these Callback functions and then add it to your view's JS section.

Thanks,
Shane

#1847353

Ok noted.

Will get back to you later

#1847741

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ibrahim,

Please provide an update when you can.

Thanks,
Shane

#1848531

My issue is resolved now. Thank you!