At my site, i use FCKEditor and IMCE as the WYSIWYG, which seems to add '/' to the links inserted. Got that handled by configuring pathologic to assume '/d6' as local path.
On top of that also got lightbox2 module enabled for automatic image handling of class="lb2img".
This is the original body field without any filter.
<a style="" href="/d6/sites/default/files/TangoCouple.jpg"><img width="180" hspace="8" height="180" align="left" src="/d6/sites/default/files/large_TangoCouple.jpg" class="lb2img" alt="" />
The resulting html with filter as listed at the rearrange filter settings:
* url filter
* html filter
* html corrector
* lightbox filter
* paging
* pathologic
<a rel="lightbox[][]" href="http://localhost/d6/?q=sites/default/files/TangoCouple.jpg"><img src="http://localhost/d6/sites/default/files/large_TangoCouple.jpg" class="lb2img" alt="" align="left" height="180" hspace="8" width="180"></a>
As u can see, the href is broken..
To workaround this issue, i changed the function pathologic_do_href as follows
function _pathologic_do_href($matches) {
// Must have no anchor
if ((empty($matches[2]))
// File must exists
&& (file_exists($matches[1]))
// Must be one of these extensions
&& (preg_match('/\.(jpg|jpeg|gif|png)$/i', $matches[1]) == true)) {
global $base_url;
return "href=\"{$base_url}/{$matches[1]}\"";
}
return 'href="' . _pathologic_url($matches[1], $matches[2]) . '"';
}
Sorry, i'm on windows.. so no patch.
Comments
Comment #1
Garrett Albright commentedDo you mean it's adding a / at the beginning? If so, that should be fine. If I'm understanding your set-up correctly, Pathologic may work just fine for you by just leaving the "Additional paths" field blank.
Comment #2
wuf31 commentedWell, it so happens that i've gotta include a '/d6' to the pathologic input format configuration.
The set-up is actually like this:
* Development: http://localhost/d6
* Production : http://my-site
Generated links at development
* href="/d6/xyz"
Without a '/d6' at the config page, results in
* href="/d6/xyz" which breaks the site, cause there's no '/d6' path here.
It's working fine with a '/d6' at the config page :)
Actually my question here is that.. what about the patch above ? Please review it, I'd love for it to be included in the official release, so that i won't need to patch it myself for every releases.
Thanks.
Comment #3
wuf31 commentedComment #4
Garrett Albright commentedOkay, I did some experimentation, and I think I'm starting to follow you.
By default, Pathologic ignores paths that begin with a slash. However, by entering a path that began with a slash ("/d6") in the "additional paths" field, those paths could no longer be ignored.
I'm sorry, but don't want to add your code because sometimes acting upon paths which end with an image extension is desired -- when the ImageCache module is used, for example.
I'm assuming simply enabling clean URLs is not an option? Or asking FCKEditor to output full absolute paths?
I'll allocate some brain cycles to this over the weekend.
Comment #5
Garrett Albright commentedwuf31, do you think you could replace your pathologic.module with the attached file and test things out for me? It includes another function call which will check if the path is kosher with Drupal's menu system. If not, it won't run it through the url() function, which is what will add the ?q= if Clean URLs are disabled. If you've already got content you're trying to use with Pathologic, keep in mind you have to edit and change the content before what the input filters spit out will change.
A caveat of this fix, though, is that if you create node A which links to node B (or any other path), and node B doesn't exist yet, but you then create node B, the link to node B from node A may not work correctly until you either edit node A or flush your site's cache_filter table -- causing the cached version of the body of node A to be dumped and the link to node B be checked again. Does that all make sense?
Another caveat is that this only works with D6 -- there doesn't seem to be a way to do this in D5, according to chx, a Drupal core developer who chatted with me a bit about it in the #drupal IRC channel. (Thanks, chx.)
Comment #6
wuf31 commentedOk, Garrett. I'll test the code and let you know how it turns out.
Thanks
PS: Somehow, it does makes sense :D
Comment #7
wuf31 commentedOk. Looks like everything turns out to be all right.
Thanks a lot, Garrett :)
PS: However, looks like i've gotta give the development "clean url" and "root" document root. Imagecache and FileField just don't play nicely without those two. Again, thanks for your effort. Appreciate it.
Comment #8
Garrett Albright commentedComment #9
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.