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 need to add a wrapper (I'll use <figure> in my example) around images posted through the editor, with a variable depending on the size image is being posted (thumbnail, medium, large, full), something like:

<figure class="$size">
    <a rel="attachment" href="....>
         <img... />

I already solved the first step, adding the wrapper with a filter through image_send_to_editor, but I can't find a way to get the image size so I can add it to the class.

Any clue?

share|improve this question

The image_send_to_editor hook passes a whole range of parameters, not just the html. One of them is the size. To get it, hook your filter passing an 8 as the number of supported parameters:

add_filter('image_send_to_editor', 'my_filter_cb'), 10, 8);

and modify your function header to grab them all:

function my_filter_cb ($html, $id, $caption, $title, $align, $url, $size, $alt) {
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.