最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

images - Partial img lazy load with WP 5.5

programmeradmin0浏览0评论

I have upgraded to WP 5.5, however the majority of the images have no loading="lazy" attribute. These images are managed by 3rd party plugins, such as Slider Revolution, Essential Grid or Siteorigin...

Could it be the plugins are disabling lazy load somehow?

I have upgraded to WP 5.5, however the majority of the images have no loading="lazy" attribute. These images are managed by 3rd party plugins, such as Slider Revolution, Essential Grid or Siteorigin...

Could it be the plugins are disabling lazy load somehow?

Share Improve this question asked Aug 18, 2020 at 8:38 RiccardoRiccardo 9711 gold badge18 silver badges37 bronze badges 2
  • You would need to ask each developer. Lazyloading will only be added automatically if they load images a certain way. – Jacob Peattie Commented Aug 18, 2020 at 8:46
  • Maybe they do this using Javascript onLoad – Riccardo Commented Aug 18, 2020 at 9:15
Add a comment  | 

1 Answer 1

Reset to default 1

Whether or not the loading="lazy" attribute will be added to images from these plugins depends entirely on how those plugins are outputting their images. As outlined in this blog post, WordPress 5.5 only adds the loading="lazy" attribute automatically to the following images:

  • images within post content (the_content)
  • images within post excerpts (the_excerpt)
  • images within text widgets (widget_text_content)
  • avatar images (get_avatar)
  • template images using wp_get_attachment_image() (wp_get_attachment_image)

So if these plugins are not adding images to the post content directly, or using the wp_get_attachment_image() function, then their images will likely not get this attribute. From experience I can say that many plugins and themes fail to use wp_get_attachment_image() even when it would be appropriate, and thus miss out on these features.

Adding the attribute to the images should be trivial, but whether that's something you could do yourself, or something the plugin's developer would need to do, is something that would be specific to each plugin. You will need to approach each plugin's developer, or consult the their developer resources, to find out. WordPress 5.5 is quite fresh though, so you may just want to give it a little time before plugins add support.

发布评论

评论列表(0)

  1. 暂无评论