Title: loading lazy
Last modified: October 20, 2020

---

# loading lazy

 *  [drumstick](https://wordpress.org/support/users/drumstick/)
 * (@drumstick)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/loading-lazy/)
 * Hi,
 * I would like to request that you add loading=”lazy” as an option for images displayed
   by the plugin. Google Pagespeed Insights complain that these images aren’t loading
   lazy.
 * Also, where can I add loading=”lazy” in the plugin files for images? I would 
   like to add it now.

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Thread Starter [drumstick](https://wordpress.org/support/users/drumstick/)
 * (@drumstick)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/loading-lazy/#post-13558947)
 * I would also like to add that I like your plugin very much!
 *  Plugin Author [Ajay](https://wordpress.org/support/users/ajay/)
 * (@ajay)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/loading-lazy/#post-13559082)
 * I have added this as a new feature to be implemented in the next major version.
 * [https://github.com/WebberZone/contextual-related-posts/issues/125](https://github.com/WebberZone/contextual-related-posts/issues/125)
 * Not tested, but try this in your theme’s functions.php
 *     ```
       function crp_ll_attr( $attr ) {
       $attr['loading'] => 'lazy';
       return $attr;
       }
       add_filter( 'crp_get_image_attributes', 'crp_ll_attr' );
       ```
   
 *  Thread Starter [drumstick](https://wordpress.org/support/users/drumstick/)
 * (@drumstick)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/loading-lazy/#post-13559107)
 * Thanks,
 * I do get this error when trying to add it to code snippets.
 * Parse Error : syntax error, unexpected ‘=>’ (T_DOUBLE_ARROW), expecting ‘;’ on
   line 2
    Parse Error : syntax error, unexpected ‘=>’ (T_DOUBLE_ARROW) on line 
   2 Parse Error : syntax error, unexpected ”lazy” (T_CONSTANT_ENCAPSED_STRING),
   expecting ‘;’ on line 2
 *  Thread Starter [drumstick](https://wordpress.org/support/users/drumstick/)
 * (@drumstick)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/loading-lazy/#post-13563952)
 * I tried the code but replaced => with =, but it didn’t show up in the img-tag.
 *  Plugin Author [Ajay](https://wordpress.org/support/users/ajay/)
 * (@ajay)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/loading-lazy/#post-13569461)
 * My apologies, it had to be a = not the =>
 * I tried the code and it does work on my test install. Where are you putting the
   code?
 * One good place to put it in wp-content/mu-plugins/ – You can create a new php
   file e.g. crp-function.php
 *     ```
       /**
        * Add lazyloading attribute.
        *
        * @param array $attr Attributes array.
        * @return array Updated attributes array.
        */
       function crp_ll_attr( $attr ) {
       	$attr['loading'] = 'lazy';
       	return $attr;
       }
       add_filter( 'crp_get_image_attributes', 'crp_ll_attr' );
       ```
   
 *  Thread Starter [drumstick](https://wordpress.org/support/users/drumstick/)
 * (@drumstick)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/loading-lazy/#post-13569480)
 * I put it in the Code Snippets plugin as a new snippet.
 *  Plugin Author [Ajay](https://wordpress.org/support/users/ajay/)
 * (@ajay)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/loading-lazy/#post-13584911)
 * That should work in theory, but am not sure when that steps in. Worth trying 
   it with your theme’s functions.php or mu-plugins as above

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘loading lazy’ is closed to new replies.

 * ![](https://ps.w.org/contextual-related-posts/assets/icon-256x256.png?rev=2985705)
 * [Contextual Related Posts](https://wordpress.org/plugins/contextual-related-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contextual-related-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contextual-related-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/contextual-related-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contextual-related-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contextual-related-posts/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [Ajay](https://wordpress.org/support/users/ajay/)
 * Last activity: [5 years, 6 months ago](https://wordpress.org/support/topic/loading-lazy/#post-13584911)
 * Status: not resolved