I would like to add the media description as a data-attribute to each image of the gallery. All the other answers favour the solution to copy the whole code from media.php to functions.php and change it there. But isn’t there a more intelligent way?
It’s way to much code duplication in order to change one single line of code!
If anybody is interested: I managed it to add a data attribute to the article thumbnail with following filter:
For the gallery I followed the advice to remove the gallery shortcode…
and then to add a customized gallery function to the functions.php…
which contains the tiny customization…