I want to use his image zoom function on my wordpress site: Medium's Image Zoom in vanilla JS
but I'm not sure how to add
attribute to all images attached in posts. What function I need to use? Can somebody help me?
You have a number of options.
You could use the
add_filter( 'the_content', 'add_data_attributes' );
And after that find the images attached to the post.
Or you can use the
image_send_to_editor filter more here.
Place this code where you run the post loop after
<?php get_footer(); ?>
<script> jQuery('.wp-post-image').attr('data-action','zoom') </script>