bobbingwide / oik

OIK Information Kit
https://www.oik-plugins.com/oik-plugins/oik
GNU General Public License v2.0
2 stars 0 forks source link

Add support for lazy loading images `loading="lazy"` #186

Closed bobbingwide closed 2 years ago

bobbingwide commented 3 years ago

In https://make.wordpress.org/core/2020/07/14/lazy-loading-images-in-5-5/ we can read about the WordPress support for lazy loading images.

Some of the <img> tags created by oik's shortcodes ( and blocks? ) are not automatically handled since

  1. They don't include width and height attributes.
  2. Nor do they include the relevant wp-image-$id class

Requirement

Proposed solution

pseudo code for setting "loading=lazy"

$extras = null;
if ( $width && $height ) {
   $extras = kv( "loading", "lazy);
}
$img = retimage( $classes, $url, $title, $width, $height, $extras );
bobbingwide commented 3 years ago

For [bw_portfolio] replace the retimage() call with bw_thumbnail_full( $matched_post )

The PHPUnit tests will need changing to cater for this change.

bobbingwide commented 2 years ago

The PHPUnit tests will need changing to cater for this change.

These changes were incorrectly reported against #187

Code was in v4.5.0. oik v4.7.2 now released. Closing therefore.