• creativiii

    (@creativiii)


    How would I go about editing the output of the Rest API so that all images within posts have the loading=”lazy” attibute?

    Tried some of the plugins and they only seem to parse inside the_content(). And doing this on my front-end would worsen load times.

    Is this even possible?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You could use the ‘rest_post_dispatch’ filter to modify the response object before it’s sent out. All API responses pass through this filter, it’s maybe an overly broad approach. Filtering “the_content” would be more specific. You could check if REST_REQUEST is defined as true if you don’t need to use your filter callback for conventional front end requests.

Viewing 1 replies (of 1 total)

The topic ‘Native Lazyload with Rest API’ is closed to new replies.