0

Been googling like crazy but come up empty. Is it possible to modify the src attribute with the core image block? I want to replace src with data-src for lazy loading images without the native functionality.

2
  • Native lazy losing is now supported in all major browsers, so there’s no reason to do this. Commented Mar 1, 2022 at 9:11
  • @JacobPeattie I kind of agree, however, the native lazy is not as flexible/tweakable as a custom lazy function can be.
    – INT
    Commented Mar 1, 2022 at 14:03

1 Answer 1

0

You want to take a look at the Codex about Block Filters.

You'll need to make a filter using add_filter and hook into render_callback by re-registering core/image and modifying the render callback.

Checkout this WPSE post from uruk.

1
  • Nice, I'll try that out, thanks!
    – INT
    Commented Mar 1, 2022 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.