WordPress.org

Ready to get started?Download WordPress

Forums

Caption Shortcode Removed on Save or Switch From Visual Editor (1 post)

  1. skunkbad
    Member
    Posted 1 year ago #

    I'm working on a little script that removes the width and height attributes from images that are inserted into a post. This works fine, even when inserting images that have captions. The problem I'm having is that when in the visual editor, upon saving, the caption is stripped, leaving the image without caption. I looked in wp-includes/media.php and I do see that in the img_caption_shortcode function that this behavior exists, but even if I comment out lines 649 and 650, the same undesired stripping of the caption happens.

    Similarly, if I am in the visual editor and switch to the text editor, the caption is removed. This could be part of tinymce, because I don't see any network activity when I do this. I looked through a little bit of the tinymce code and had no clue.

    Now, I do need help (or a few hours of banging head on keyboard), but I wonder why WP doesn't have an option to remove the width and height attrs by default. I know there are some CSS work-arounds, but I just like to complain!

Topic Closed

This topic has been closed to new replies.

About this Topic