This may be user error, or perhaps not what the module was intended to do, however I am looking for the ability to replace the URL's within a text area with the new clean version based on Drupal's base_path.

For example, say I have two environments, one is /dev/, one is /live/. I am then working on the dev version and add in an image with IMCE or some other editor and the path is:

/dev/sites/default/files/image.jpg

I then copy my dev DB over to the live environment. Now I understand that Pathologic still allows the image to display correctly when viewing the node, even though the path is still saved as /dev/, however when you go to edit that node, the image no longer displays in the WYSIWYG editor because the path is still /dev/ rather than updating to /live/.

I'm wondering if it's possible to make the module rewrite the URL on save relative to base_path so this:

/dev/sites/default/files/image.jpg (which breaks in WYSIWYG if on /live/)

would save as:

sites/default/files/image.jpg (which works in WYSIWYG in both /live/ and /dev/)

Basically it would use any configured paths as a way to clean a URL upon saving. URL's would then be consistently based on base_path and the module can easily add the absolute or relative path in as it current does when viewing the node. I guess the other option would be to automatically update the /dev/ to /live/ when the edit form is loaded.

Anyways, this module is great and I really appreciate all the hard work. Let me know if my logic is flawed or maybe the module already does this and I'm just not configuring it right.

Comments

Garrett Albright’s picture

You may have a little bit of a misunderstanding of how the module works, yes; input filters in general, actually. When content is saved to the database, it is (unless something is doing something weird) completely unfiltered; exactly as it was input. When content is displayed (a node is viewed), only *then* is it filtered, and that's when Pathologic and other input filters are run. So the paths you input on the /dev/ site will still have the /dev/ path when saved, but when the node is viewed, then Pathologic runs and translates the paths if it deems it necessary. You can confirm this by temporarily disabling your WYSIWYG editor and checking out the paths; they will be the same as entered in the database, with the /dev/ path.

WYSIWYG editors muddy this, however, since they allow content to be "viewed" without it actually being "viewed" according to Drupal, if you get what I'm saying. So that's why your paths aren't working with the WYSIWYG editor.

Now back when I had to install CKeditor for clients, I recall its module had a feature where it could run content through a text format before loading it into the editor. If the module you're using has such a feature, you could create a new text format which only has Pathologic, then configure the module to run the content through that format before it's brought into the editor. The caveat of this is that, when you next save the content, it will save the paths as corrected by Pathologic; but perhaps this won't be a problem. You may want to try some experimentation in that direction.

(Me changing Pathologic to actually save corrected paths to the database is not an option; I've gone out of my way to not allow Pathologic to do un-Drupal-like things as much as possible.)

michaellander’s picture

Status: Active » Closed (works as designed)

Thanks Garrett,
I had assumed this was a case and I appreciate the possible solution. Clients generally don't understand the environment stuff as we do so I was just looking for a solution or some sort to fix that, a sort of 'cure all' or ideal if you will. I appreciate your commitment to keeping pathologic true to Drupal's current way of handling things. Thanks again.