• Resolved Lenin-Kerrigan

    (@lenin-kerrigan)


    Have a problem with wp.editor used in Theme by users
    in a custom_post page i have a popup window with wp.editor in it to edit content for custom posts

    It’s looks like this

    http://tourist.club/wp-content/uploads/2019/06/57.jpg

    when I’m adding an image throw wp.media, it is inserting with absolute URL like this

    http://tourist.club/wp-content/uploads/2019/06/58.jpg

    But when I’m getting content throw wp.editor.getContent(id) or change view from html to WYSIWYG and versa. It’s changing src to relative, like this

    http://tourist.club/wp-content/uploads/2019/06/59.jpg

    offcourse after this, in the post this url don’t work, cause it’s try to load image from

    site.com/current_page/wp-content/uploads…
    when image is in
    site.com/wp-content/uploads…

    I can make dirty fix buy changing relative url to absolute while saving the post data, but seems this problem should have more easy way to resolve buy changing some wp.editor settings or something like this…

Viewing 3 replies - 1 through 3 (of 3 total)
  • Look in the code for WP prior to 5.0, to see how it is handled in core. Or look at a plugin that adds the editor to other areas (like text widget or taxonomy descriptions). I’m sure the problem has been solved before.
    https://wordpress.org/plugins/search/rich+text/

    Thread Starter Lenin-Kerrigan

    (@lenin-kerrigan)

    I find only this in wp-admin/js/editor.js

    wp.editor.getContent = function( id ) {
    		var editor;
    
    		if ( ! $ || ! id ) {
    			return;
    		}
    
    		if ( window.tinymce ) {
    			editor = window.tinymce.get( id );
    
    			if ( editor && ! editor.isHidden() ) {
    				editor.save();
    			}
    		}
    
    		return $( '#' + id ).val();
    	};

    and

    switchEditor( id, mode )
    which is too large to copy paste it here

    But in this functions is totaly nothing about changing url in the content…

    Thread Starter Lenin-Kerrigan

    (@lenin-kerrigan)

    Hi. Problem is solved, i find what wp_editor initialize object has a special parametr for url saving, it’s name

    relative_urls

    It should be set to false, if you use wp_editor in frontend part of the site.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘wp editor change img src’ is closed to new replies.