0

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.

1 Answer 1

0

I think from the Media manager if you click on any image/file there are fields on the right side for Alt text and description....

I guess the Spotlight plugin will get these data from there to use.

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