In my functions.php
I have cooked up some functions to filter the attachment output code, when an attachment is sent to the editor.
function filter_image_send_to_editor($html, $id, $caption, $title, $align, $url, $size, $alt) {
$arr = get_attachments_and_widths_arr($id);
return attachments_and_widths_to_html($arr, $id, $align, $caption, $alt);
}
add_filter('image_send_to_editor', 'filter_image_send_to_editor', 10, 9);
The return statement returns a string that contains pure html code and already has the caption text properly added to it. The problem is that because the Media Libary
has some text in the 'Caption' field for that image and it automatically adds the [caption]
shortcode around my html code after the above function returns. So I guess strip_shortcode()
will not work in my case, since the string I am returning as filtered code does not yet have any shortcode, [caption
] is added after the function returns.
How do I prevent this from happening?
EDIT: I know about this post, but I would like WP not to send any shortcode to the editor at all. The solution in that post removes the [caption] code when the post html is generated.