• cristobal-galleguillos-katz

    (@cristobal-galleguillos-katz)


    Hi!
    I want to insert the text in the “description” field of an image, automatically, just as the “caption” field is inserted.
    How can I do that in an “elegant” way? (Not hacking the source, perhaps using hooks or something).

    I’m using TinyMCE as is included in the installer.

    Thanks in advance,
    CGK.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    You can override the caption shortcode output entirely with the img_caption_shortcode filter.

    function my_caption($output, $attr, $content) {
    // do whatever you need to create the output, which starts out blank
    return $output;
    }
    add_filter('img_caption_shortcode','my_caption');

    Look in the wp-includes/media.php file, at the img_caption_shortcode() function. That’s how it does it.

    Thread Starter cristobal-galleguillos-katz

    (@cristobal-galleguillos-katz)

    Thanks, that gave me some insight on how it works.
    I’ve managed to display the description in the post by writing a new function and attaching it as a filter, but by doing it that way it won’t get displayed in the editor, as the caption does.

    Is there a way to do so?

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to display image description in the caption’ is closed to new replies.