I have to add an attribute on WP images to add description on Spotlight lightbox. I tried the wp_get_attachment_link filter but it doesn't work.
function add_data_description_link($content, $post_id) {
$description = get_post_field('post_content', $post_id);
$data_description = ' data-description="' . esc_attr($description) . '"';
$content = str_replace('<a ', '<a' . $data_description . ' ', $content);
return $content;
}
add_filter('wp_get_attachment_link', 'add_data_description_link', 10, 2);
Nothing happens. It seems that the filter does not work at all.