Search code examples
imagewordpresstinymcewysiwyg

Wordpress WYSIWYG image links broken


In a custom plugin I invoke a WYSIWYG editor like this:

<?php the_editor(get_option("reminder_text"), 'reminder_text'); ?>

Everything works fine, until I try to insert an image (uploader or external source, no difference).

Example: I enter the image path and the image is displayed correctly. When i save the form and return to it, the image is displayed as broken and the path is surrounded by escaped quotes, e. g.:

\"http://www.my-image-link-here.jpg\"

Has someone an idea how to solve this problem?


Solution

  • That's because the data is sanitized when inserted in the database, you need to clean up the returning results of get_option.

    Take a look at the documentation about Data Validation.

    Use:

    the_editor( esc_attr( get_option( "reminder_text" ) ), 'reminder_text' );
    

    Related answer at WordPress StackExchange.