|
|
View previous topic
::
View next topic
|
Author |
Message |
ramon fincken Site's programmer
 Get a free globally recognized avatar It's free!
Joined: 03 Aug 2007 Posts: 414 Location: A'dam/Diemen, The Netherlands
|
Posted: Tue Jun 18, 2019 11:25 am Post subject: [solution] WordPress a3 Lazy Load plugin Background image inline |
|
|
The WordPress a3 Lazy Load does not work for background images in HTML.
The lazy load javascript comes from https://github.com/ressio/lazy-load-xt
its readme shows this nice example: http://ressio.github.io/lazy-load-xt/demo/bg.htm
steps to enable background image lazy loading for WordPress:
Code: |
add_action( 'wp_enqueue_scripts', 'enqueue_javascripts' );
function enqueue_javascripts() {
/**
* https://github.com/ressio/lazy-load-xt
* http://ressio.github.io/lazy-load-xt/demo/bg.htm
*/
$in_footer = true; // Overwrite any setting from a3 lazy loading
wp_register_script( 'jquery-lazyloadxt-bg',
get_template_directory_uri().'/dist/js/jquery.lazyloadxt.bg.js',
array( 'jquery', 'jquery-lazyloadxt', 'jquery-lazyloadxt-srcset', 'jquery-lazyloadxt-extend' ),
A3_LAZY_VERSION,
$in_footer );
wp_enqueue_script( 'jquery-lazyloadxt-bg' );
} |
Convert your background HTML element URL calls like:
Code: | style="background-image: url(image_url.jpg)" |
to:
Code: | data-bg="image_url.jpg" |
done! |
|
Back to top |
|
 |
Google adsense Advertisement
|
Posted: Tue Jun 18, 2019 11:25 am Post subject: [solution] WordPress a3 Lazy Load plugin Background image inline |
|
|
Advertisement
|
|
Back to top |
|
 |
GravityForms Advertisement
|
Posted: Tue Jun 18, 2019 11:25 am Post subject: [solution] WordPress a3 Lazy Load plugin Background image inline |
|
|
Advertisement
 |
|
Back to top |
|
 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|