A)
I've just noticed this issue with my website, which is installed in a subdirectory: public_html/web

When *viewing* a page, its url is, for example, http://domain.net/web/content/welcome
(clean urls and pathauto enabled)

I erroneously thought that because 'web' is a real directory, and 'content' is just a url rewrite, that 'web' would still be the base-url of the node, so that a link to an image inserted in this page would be:
img src='sites/default/files/images/image01.jpg'
This would be great because it means the website could be moved anywhere in the future and the links would still work. I actually thought all internal image and file links would work this way, so I would have the flexibility to:

1) move the site from sub-directory to root or vice versa
2) rename the installation subdirectory
3) clone the live site in another sub directory for test/dev purposes
4) change 'local-path' pathauto aliases

Unfortunately this doesn't seem to be the case - it is the url displayed in the browser bar which is the important reference, and therefore 'content' is actually the node's location in this example. So instead, the file needs to be linked relatively from 'content' using:
img src='../sites/default/files/images/image01.jpg' (which I can't expect my users to use)
or using:
img src='/web/sites/default/files/images/image01.jpg' (which isn't portable)

My question is simple - if internal image and file links in the website content use the latter format, will pathologic allow me the flexibility/portability I described earlier (especially the cloning of the site from 'web' to 'test') and still have all the internal links function properly?

B)
I just read in another thread here that this module puts a large load on the database.
Does this allegation have any basis?

Thanks.

Comments

Garrett Albright’s picture

A)

In this case, it is the intention of Pathologic that you would be able to use a path such as sites/default/files/images/image01.jpg and have it always work; if your site is on domain.net, Pathologic will convert the path to http://domain.net/sites/default/files/images/image01.jpg.

B)

Where did you read this? Could you link to the thread?

Pathologic does hit your database as well as your file system when it does its magic -- the former to see if paths you are linking to exist in the Drupal installation, and the latter to see if you're linking to actual physical files. However, Drupal caches the results of output filters, so unless you have something unusual going on with your installation that's stopping that caching, the work that Pathologic (and other input filters) performs is only occurring when you save or preview a node (and have made changes to the field since the last time you saved/previewed it). It is not happening with every single view of that node.

-Anti-’s picture

Thanks for your reply.

> A) In this case, it is the intention of Pathologic that you would be able to use a path such as sites/default/files/images/image01.jpg and have it always work; if your site is on domain.net, Pathologic will convert the path to http://domain.net/sites/default/files/images/image01.jpg.

That's great, but does it work if drupal is in subdirectories? The main issue I have is that my live site is in public_html/web and I'd like to regularly clone (copy) it every couple of weeks to public_html/test for continued development and testing...

If a user on the live site added a link to an image or file using TinyMCE or IMCE, the path will be:
/web/sites/files/images/image01.jpg

When I clone the live site to the /test directory, can pathologic then filter that path and change it to:
/test/sites/files/images/image01.jpg

Thanks for any further clarification about this.

B) Hass, in the pathfilter thread said it: http://drupal.org/node/267882

Cheers!

Garrett Albright’s picture

If a user on the live site added a link to an image or file using TinyMCE or IMCE, the path will be:
/web/sites/files/images/image01.jpg

When I clone the live site to the /test directory, can pathologic then filter that path and change it to:
/test/sites/files/images/image01.jpg

No… It's tricky. By default, Pathologic ignores absolute paths -- ones that begin with a slash. The way around this is to either tell TinyMCE to not use absolute paths, or to tell it to use them -- but also include the http:// part, so it would output http://example.com/web/sites/files/images/image01.jpg and http://example.com/test/sites/files/images/images01.jpg depending on which installation you're using. You would then tell Pathologic to consider both http://example.com/web/ and http://example.com/test/ to be local; see the "Is configuration necessary?" section of the documentation.

As for the thread you linked to above… ah, I had forgotten about that. I actually did propose merging my work with that of the Path Filter crew, but they didn't seem too receptive to the idea…

pramudya81’s picture

Really good module But Im having problem like Anti.

By default TinyMCE using "/" like /files/image.jpg thus pathologic does not work.
Im still on D5 and TinyMCE 3 so there is no option to tell TinyMCE to have absolute path.
I thought this module could be the rescue.

What is your suggestion here?

Regards

-Anti-’s picture

Status: Closed (fixed) » Active

I should mention that I solved my problems descibed above in this thread by using subdirectories instead (and htaccess to stealth the main-site's subdomain). So all my internal urls are: /sites/default/files/etc with TinyTinyMCE and IMCE.

So I'm going set this thread to closed.

pramudya81, you should start a new thread because although the problem is the same, your purpose is different: It is about external rss feed services breaking your links. It might require a different solution from the pathologic developer.

However, one fix that I'll mention here would be to open tinymce.module -

find the line: $init['document_base_url']
and add underneath or above: $init['convert_urls'] = "false"; if it isn't already there.

Also find the line:

$host = $base_url; or $host = base_path();
and edit it to:
$host = "http://www.yourdomain.com/";

And in IMCE, I think the should be an 'absolute url' checkbox under 'common' in the set-up page.

I think this will make all your urls added with tinymce/imce 'domain absolute'.

Now, as we discussed in the forum, absolute urls in websites are a terrible idea, and you'll never catch me putting them in my site. However, if you decide to use them and have to move your site in the future, you'll be able to use pathologic to adjust your urls - it *will* work with them this time, because they will be all 'domain absolute', rather than 'path absolute' as they are now.

pramudya81’s picture

Yes I agree with you, Anti. Absolute path should be avoided. Ok I'll make a new issue on this. And let's see what pathologic could offer.

-Anti-’s picture

Status: Active » Closed (fixed)

> [domain] absolute paths should be avoided.

However, if that is the only way you can get your external feed services to work, then editing tinymce/imce to produce 'domain absolute' urls might be your only choice. And if you do have to use 'domain absolute' urls, at least pathologic will be able to help you out if you need to move your site in the future.

Closing thread.

Garrett Albright’s picture

Issue summary: View changes
Status: Active » Closed (fixed)

Reclosing issue… it's showing up as open on the issue queue for some reason.