get_image_tag & wp_get_attachment_image_attributes behaving strangely

Featured images are stored separately in the database and retrieved with a separate function. So it is possible to attach a filter to that function. Regular images are just strings in the post field or in a widget. You can still filter those, but it takes more effort. The filter you built on get_image_tag can also be used on the_content (for posts and pages) and widget_text (for the text widget).

Beware that if you have already used the filter on get_image_tag, your data attribute is already included as a string in the post, so if you use the filter again it will be included twice, unless you include a test for its presence.

As for the hyphen in the data attribute, that’s simply how the attribute is defined. Just data is invalid html.