Add Lazy Load and Lity Lightbox to content images

We had a client who has thousands of images in their blog posts over the years.

We needed to make sure all of those images have lazy load and appear in a lightbox when clicked.

Obviously this requires you to install a lazy load plugin and a light box plugin. I recommend these:

Lazy Load: http://jquery.eisbehr.de/lazy/

Lity Lightbox: https://sorgalla.com/lity/

Now the code!

 

Download and Update Post Content Images

Sometimes we have clients who have a lot of old blog posts. Often these blog posts have a lot of images in the content. Sometimes they are uploaded locally…sometimes they are not. I actually think serving images from 3rd parties is a great idea to offload the cost to your servers, but sometimes clients will request that we update their blogs so all the images are being served from their site.

Here is a quick script I wrote to do just that.

Good luck!