WordPress Developer Ukraine, Kyiv
WooCommerce Product Gallery: Images, Sideloading, and REST API

WooCommerce Product Gallery: Images, Sideloading, and REST API

WooCommerce product images from URLs: sideload, gallery and REST API Product data from a supplier usually comes with image URLs, not files. The WooCommerce REST API can take those URLs and download the images itself, and in PHP the same is done with media_sideload_image() plus set_image_id() and set_gallery_image_ids(). The parts that are easy to get…
Lazy Load Images and Iframes in WordPress with the Native Loading Attribute and IntersectionObserver

Lazy Load Images and Iframes in WordPress with the Native Loading Attrib ...

Lazy load images and iframes in WordPress with the native loading attribute Since WordPress 5.5, images printed through the_content(), the_post_thumbnail() and wp_get_attachment_image() get loading="lazy", and since 5.7 iframes too. The browser then downloads off-screen images only when the visitor scrolls near them, without any JavaScript, which saves a lot of traffic on image-heavy pages. All…