2

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.

1 Answer 1

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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