WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have written a plugin which does some fancy stuff with GD lib when you upload an image.

Everything is working fine, however I need to get the image title and add it to the image URL (and file name of the image) when the user clicks 'insert into post', but can't find any references which could help me.

share|improve this question
up vote 1 down vote accepted

You need to use the filter image_send_to_editor.

add_filter('image_send_to_editor', 'wpse_62869_img_wrapper', 20, 8);

function wpse_62869_img_wrapper( $html, $id, $caption, $title, $align, $url, $size, $alt ) 
    return $html;

These are the values of a test insert and you can use them to build your own $html response.

html     |  <a href="http://wp34.dev/wp-content/uploads/2012/11/escritorio.jpg"><img src="http://wp34.dev/wp-content/uploads/2012/11/escritorio-224x300.jpg" alt="Alt text for the image" title="escritorio" width="224" height="300" class="aligncenter size-medium wp-image-9" /></a>
id       |  9
caption  |  The image caption
title    |  escritorio
align    |  center
url      |  http://wp34.dev/wp-content/uploads/2012/11/escritorio.jpg
size     |  medium
alt      |  Alt text for the image
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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