Forums

relative URL converted to abs URL in Visual Editor 2.5 (20 posts)

  1. eynugget
    Member
    Posted 1 year ago #

    Started using 2.5 today.

    The visual editor seems to always want to convert relative URLs to absolute urls in my image tags. So:

    <img src="images/hello.gif"> gets converted to
    <img src="http://www.mydomain.com/wp/wp-admin/images/hello.gif">

    My wordpress dir is "wp".

    So why is it doing this and how can I stop it?

    These relative links were working fine in 2.3.3.

    Help, anybody!

  2. circumambulant
    Member
    Posted 1 year ago #

    I noticed the same problem. I can use the HTML editor rather than the Visual editor to fix the links. It is a cumbersome work-around for this problem.

  3. Otto42
    Moderator
    Posted 1 year ago #

    Relative links are not recommended. They break whenever you change to using non-default permalink settings.

  4. guitarnoise
    Member
    Posted 1 year ago #

    I can see the valid argument for using absolute urls. But is there a way to disable the "forced absolute urls" in 2.5? It is proving cumbersome for editing older posts, and I would like to be able to stick with relative links at least temporarily.

  5. guitarnoise
    Member
    Posted 1 year ago #

    Actually I found a solution by looking in the code for the tiny_mce_config file.

    I replaced
    'relative_urls' => false,

    with
    'relative_urls' => true,

    Which allows me to do exactly what I wanted to do, and I can change it back later.

  6. eynugget
    Member
    Posted 1 year ago #

    Hmm...

    Seems to me the absolute links make the site pretty non-portable.
    Well, that's not too bad since we don't change the location of the site all that often.

    The real problem is that, by default, it stuffs the "/wp-admin" thing in there and that breaks the reference.

    I have found that the workaround in the Visual Editor is to just modify each image src= to "../images/hello.gif". This then gets changed to "http://www.mydomain.com/wp/images/hello.gif" and wordpress will not add the "/wp-admin" when saving.

    But, I have to do this to dozens images manually. Less cumbersome than circumambulant's workaround.

  7. schamane
    Member
    Posted 1 year ago #

    Thanks guitarnoise for this advice. For those who want to try it, guitarnoise was referring to the file wp-includes/js/tinymce/tiny_mce_config.php

    Unfortunately, this enforces relative links (and does not tolerate absolute links; or at least this is what I found). I am afraid it will only help some people.

    Personally, I'd appreciate it if the bug (adding wp-admin to relative links) was fixed. Besides, I guess I'll once again have to resort to the non-visual HTML editor :(

  8. skeezicks
    Member
    Posted 1 year ago #

    This is for Otto42:

    You said:

    Relative links are not recommended. They break whenever you change to using non-default permalink settings.

    This is not a decision that WP or TinyMCE should make, and it telling folks "Don't do that" doesn't help with their frustration.

  9. Otto42
    Moderator
    Posted 1 year ago #

    @schamane:

    Personally, I'd appreciate it if the bug (adding wp-admin to relative links) was fixed.

    Try adding this to that array in tiny_mce_config.php, see if it works:
    'document_base_url' => get_option('url'),

    If it does, I'll see about getting it into trac.

    @skeezicks:
    It may not help with their frustration, but it will help them prevent problems in the future by using correct absolute URLs instead of relative ones. When they start using non-default permalinks and suddenly every link they've ever made breaks, well, then we have to tell them "yeah, you messed up originally, go undo all that work you've done for the last long time period", then that's a tad more frustrating, no?

    Relative URLs are tools of evil and should be avoided whenever possible.

  10. skeezicks
    Member
    Posted 1 year ago #

    Circumambulent's workaround about using the HTML editor worked for me (IIRC). Thanks for the help!!

    Then I began using TinyMCEAdvanced (supposedly fixed for WP2.5).

    Problem came back.

    I went through Schamane's workaround for TinyMCE and will see how that works out for me (Thanks, Schamane!)

    I also checked whatever Tinymceadvanced files I could find for a similar callout but was not able to find any, so I guess it's back to TinyMCE for awhile.

  11. skeezicks
    Member
    Posted 1 year ago #

    To Otto42:

    First of all, thanks for your help. Please forgive my frustration. It just seems that I constantly have to fuss and fidget around with my blog to get it to work right.

    It's like MSWord's multi-level list functionality. No matter how much care one puts into formatting a multi-level list, it seems it is always boogered the next time the file is opened.

    A few months back, and in another forum (bluehost, I believe) I got the idea that the inclusion of absolute urls in blogs opened doors to spambots, and that keeping urls relative would help. That's my big hangup with absolute vs. relative urls. Maybe whoever wrote that advice was incorrect, I dunno.

    Sometimes it seems that I spend much more time trying to prevent problems than I would spend just fixing the problems if and when they occur.

  12. Otto42
    Moderator
    Posted 1 year ago #

    A few months back, and in another forum (bluehost, I believe) I got the idea that the inclusion of absolute urls in blogs opened doors to spambots, and that keeping urls relative would help. That's my big hangup with absolute vs. relative urls. Maybe whoever wrote that advice was incorrect, I dunno.

    I've never heard of that one before. I kinda see what they're thinking, but it's stupid.

    Basically, the idea here is that the spam bot isn't able to turn bob/your/uncle.html into http://example.com/bob/your/uncle.html . However, the idea is incorrect because a) browsers can do it and b) so can mirroring program like wget and c) it's literally like only 5 lines of string manipulation code to do it. One line of regexp. So thinking that it somehow prevent spambots from finding things is just straight up wrong and silly. Sorta like the silly idea that using "at" instead of "@" in email addresses fools email harvesters.

  13. skeezicks
    Member
    Posted 1 year ago #

    Thanks for the clarification!

  14. azaozz
    Member
    Posted 1 year ago #

    The proper setting for tiny_mce_config.php is
    'convert_urls' => false,

    This will preserve the URLs as entered, either relative or absolute.

  15. skeezicks
    Member
    Posted 1 year ago #

    Well, it works for me. Today anyway ;)

    BTW, the workaround holds up also if one uses TinyMCEAdvanced.

  16. schamane
    Member
    Posted 1 year ago #

    @Otto42: 'document_base_url' => get_option('url'), does not work. I guess this is because while editing a post the current URL is http://myhost/sth/wp-admin/post.php.

    Thanks to azaozz. Since I prefer relative URLs anyway, 'convert_urls' => false, is what I was looking for. Strangely though, it works only if I also set 'relative_urls' => true,.

  17. Kalessin
    Member
    Posted 1 year ago #

    I came to this thread from http://wordpress.org/support/topic/166192?replies=7 which raised similar issues. I'm pleased to see a solution is available!

    Having read through the discussion about relative versus absolute links, I found a solution some years ago, the RKG Page Permalinks plugin (scroll down to point 10).

    You can link to other pages using something like /index.php?page_id=12 and the plugin converts it to a permalink when the page is displayed, using your current permalink settings.

    This means that you will always have pretty URLs, and they will always work, even if you change the permalink structure or the page slug afterwards!

    This is always one of the first plugins I install.

  18. bmohr
    Member
    Posted 1 year ago #

    I made these 2 changes to the array in the tiny_mce_config.php:
    'convert_urls' => false
    'relative_urls' => true

    and then tested it by making a relative path to one of my images and it does not work. Any other suggestions?

  19. wdm
    Member
    Posted 1 year ago #

    don't forget to add commas - so the array in your wp-includes/js/tinymce/tiny_mce_config.php should end like:

    'old_cache_max' => '1', // number of cache files to keep
    'convert_urls' => false,
    'relative_urls' => true'

  20. jarom1
    Member
    Posted 1 year ago #

    Hmmm... Is there something different about wp 2.6 regarding this issue?

    I'm using absolute urls pointing to pages in the same domain name that are not wp posts and wp is automatically converting my absolute urls to relative urls. Example:

    in my post at http://www.realestateinvestingforbeginners.com/advice-and-mentoring/investing/an-inexpensive-way-to-find-deals/

    the "investing strategies" link was:
    http://www.realestateinvestingforbeginners.com/investment_strategies.php

    wp turned it into:
    ../../investment_strategies.php

    which effectively points to: http://www.realestateinvestingforbeginners.com/advice-and-mentoring/investment_strategies.php

    which doesn't exist.

    In tiny_mce_config.php the settings have always been
    'relative_urls' => false,
    'convert_urls' => false,

    Any thoughts would be great, and I appreciate the help. I agree with skeezicks though--creating pages in wp is like having to code for a whole new browser. It's reminiscent of when you had a site looking great in IE and then you'd have to fiddle endlessly with it to make it look right in Netscape too.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.