relative paths to images

Post Reply
User avatar
Jay
Master Bludit
Posts: 133
Joined: Mon Feb 11, 2019 8:41 pm

Howdy
I'm wondering what is the easiest way to get relative urls of inserted images instead of absolute ones (domain prefix)?

I've found in init.php an entry

Code: Select all

// TRUE to convert relatives images to absoultes, FALSE No changes apply
define('IMAGE_RELATIVE_TO_ABSOLUTE', $site->imageRelativeToAbsolute());
is it enough to comment this line?
User avatar
diego
Site Admin
Posts: 773
Joined: Sat May 16, 2015 2:53 pm
Been thanked: 1 time
Contact:

Hi,
if you have a page content like this

Code: Select all

<img src="my-image.png" />
and you set TRUE that constant, Bludit is going to parser the content of the page and show to the user the next code.

Code: Select all

<img src="http://www.example.com/my-image.png" />
User avatar
Jay
Master Bludit
Posts: 133
Joined: Mon Feb 11, 2019 8:41 pm

diego wrote: Mon Mar 11, 2019 1:44 pm Bludit is going to parser the content of the page and show to the user the next code.
ohhh that clarifies this constant.
It is just that its behaviour is a bit weird to me along with variable

Code: Select all

$imagesURL = (IMAGE_RELATIVE_TO_ABSOLUTE? '' : DOMAIN_UPLOADS_PAGES.$uuid.'/');
set in kernel\admin\themes\booty\html\media.php

If I set the constant to true, and img button inserts only img filename in editor's textarea, outputed html page code contains absolute path to img.
So far so good.
But I've got some kind of a media directory for "global" images used on couple pages, not to duplicate the img files in every article.
The problem appears, when I try to insert a path to img located in this directory when IMAGE_RELATIVE_TO_ABSOLUTE is set to TRUE.
It is also parsed and gets the absolute path to posts directory, thus making the img URI wrong.

There's no problem with deleting the domain in inserted absolute path with default constant state, but I need to remember doing it all the time.
So shouldn't inserted in textarea path to img be relative in IMAGE_RELATIVE_TO_ABSOLUTE default behaviour?


ps. I can't set IMAGE_RESTRICT constant as the img manager doesn't support directory nesting.
Post Reply