I want my editors to be able to use the default "Insert Media" feature but I want to customize the output. By default, "Insert Media" produces something like this:
[caption id="attachment_414" align="aligncenter" width="600"]<a href="http://www.theharbiner.com/?attachment_id=414" rel="attachment wp-att-414"><img src="http://www.theharbiner.com/media/2014/06/baskets-of-tea-1-600x397.jpg" alt="Baskets of Tea" width="600" height="397" class="size-medium wp-image-414" /></a> Varieties of tea on display and for purchase.[/caption]
Wow! That’s a lot. And it contains a mix of shortcode, hardcoded HTML and a lot of hard-coded attributes.
What I want the output to be is (for a single image):
[image id="414"]
Simple!
This would be easier for my editors (who don’t know HTML) and it’s future proof – I can regenerate images at different sizes and change HTML and attributes any time as I develop the theme. It also looks good alongside the Markdown that I’m making all my editors use.
I have already written the shortcode functions to output the desired HTML in my theme. What I need to do is filter the returned output of the actual "Insert Media" function in the post editor.
Is this possible? What is the filter to use?
Note: The answer is not img_caption_shortcode. That filter is for modifying the HTML output by the theme.