Add plugin structure, lazy load feature, and basic admin settings

This commit is contained in:
Marcus Quinn
2025-03-13 00:25:51 +00:00
parent 544aa4533d
commit dc9697e015
3 changed files with 81 additions and 5 deletions

View File

@ -0,0 +1,18 @@
<?php
/**
* Speed optimization functions
*/
function wpa_superstar_lazy_load_images( $content ) {
if ( is_admin() || ! $content || ! get_option( 'wpa_superstar_lazy_load', 1 ) ) {
return $content;
}
$content = preg_replace(
'/(<img[^>]+)\/?>/i',
'$1 loading="lazy" />',
$content
);
return $content;
}
add_filter( 'the_content', 'wpa_superstar_lazy_load_images' );
add_filter( 'wp_get_attachment_image', 'wpa_superstar_lazy_load_images' );