• NL_Derek

    (@nl_derek)


    When I add an image WP creates an absolute link like: https://www.mysite.com/wp-content/blah/blah/mypicture.jpg. If a user does a search for mysite every page with an image will be found. A similar problem occurs with links to another page. Since my site name (binnenstadduurzaam) comprises the (Dutch) words for “city-center” and “sustainable”, such a search is quite likely.

    My workaround is to manually edit the links to be relative thus: ../wp-content/blah/blah/mypicture.jpg. This is time-consuming and error-prone, so I am looking for a better solution.

    I found several plugins which offer conversion from absolute to relative paths, but all but one are several years old and “untested for your version”. The plugin “Make Paths Relative” seems to be up-to-date but does not work on my test site (preview pictures in the Media Library are not displayed). The test site is (something like) https://private.mysite.com/wp-test/; possibly the use of a different subdomain causes problems. Obviously I daren’t test it on my live site https://www.mysite.com.

    Is there an up-to-date plugin which does what I want? or does the lack of plugins indicate that there is a WP option which I haven’t found? Or is there a better workaround? The problem exists with themes 2020 and Neve.

Viewing 2 replies - 1 through 2 (of 2 total)
  • mrtom414

    (@mrtom414)

    WordPress has functions to manage the paths. Are you creating a html file or using WordPress templates ? You can try using functions like get_template_directory_uri. If you are using a block ,plugin, or theme short codes, They should do the heavy lifting for you. it should take care of the paths after you upload the image. You can’t really use a relative path because the developer of the theme would have no ideal how your sites has been uploaded. The URL that are used in WordPress are generated permalinks. Their is no physical page! All pages are generated using the same templates. If you placing a link to an html page you coded, the link would be relative to your page. But, It would not reside as part of WordPress. If you want WordPress to manage the paths you will need to create a plugin, theme Template.

    Thread Starter NL_Derek

    (@nl_derek)

    Thanks for your reply mrtom414. I use WP as a CMS for a simple website, and use the Gutenberg block-editor as much as possible.

    If I understand correctly the answer to my question is: no, there is no general solution. Creating a plugin or theme variant is (way) over my pay grade!

    So I shall continue diving into the HTML and editing the paths (fortunately my site is not very big or image-heavy).

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Absolute or Relative Paths’ is closed to new replies.