WordPress.org

Ready to get started?Download WordPress

Forums

WP2.6 Captions question (6 posts)

  1. cnymike
    Member
    Posted 5 years ago #

    So version 2.6 has added this automatic captions to images. Not sure if I like that. Of course all images need an alt tag, but why is this automatically providing a caption to the image as well? Seems to me that a caption should be its own field, not tied to the alt tag field.

    Is there no way to remove a caption but via the HTML editor? Is there no way to prevent a caption from being added to an image in the first place?

  2. tarr
    Member
    Posted 5 years ago #

    don't put captions and images won't have captions.

  3. cnymike
    Member
    Posted 5 years ago #

    Images need alt tags to be compliant with standards. WP uses the alt tag to also generate a caption. This is not desirable. There should be a separate caption field if you want a caption. You should not have to have remove the caption code manually in order to ensure that you have an alt tag without an unwanted caption.

  4. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    One line of code disables all captions as of 2.6.2. Put it in a plugin or in your theme's functions.php file.

    add_filter('disable_captions', create_function('$a','return true;'));

  5. cnymike
    Member
    Posted 5 years ago #

    Thanks Otto42. That'll work for me for the time being.

    However, I'd would like to see separate fields in the Add Media interface to deal with this issue rather than be forced to disable all captions. There may be an instance where I want a caption.

    I'll leave this as unsolved since your suggestion is a workaround rather than the more usable solution I seek.

  6. alisonn
    Member
    Posted 5 years ago #

    add_filter('disable_captions', create_function('$a','return true;'));

    Does this have the same problem as the 2.6.1 hack* i.e. you lose the align class with it?

    *function no_caption($deprecated, $attr, $content) { return $content; };
    add_filter('img_caption_shortcode', 'no_caption', 10, 3);

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags