4

I have developed a new CCK module using Plupload where users can drag and upload images using native HTML5 apis. Since, I do not know how to drag images directly inside CKEditor, what I am doing is that after images are uploaded using plupload's jQuery widget, I show an image instead of a filename from where users can drag that image inside a CKEditor. Its a 2-step drag-n-drop process.

Now, when I drag & drop images into a CKEditor using Chrome, CKEditor generates following code

<p>
    <img src="http://myportal/sites/myportal/files/plupload/p15sjkcj2c1o3koe3hsp19761ep14.jpg" /></p>

When I do similar action using Firefox/Safari, CKEditor generates following code

<p>
    <img src="../../sites/myportal/files/plupload/p15sjle1js11r5289aibk0m1n7q3.jpg" /></p>

Problem is depending on from where I am viewing the node (views, panel etc), images sometimes shows up and sometime not, because they point to location starting with ../../ and not with http://myportal/.

So, how do I make sure that when Drupal is generating node's view, "../../sites/myportal/files/plupload/p15sjle1js11r5289aibk0m1n7q3.jpg" is expanded or converted to "http://myportal/sites/myportal/files/plupload/p15sjkcj2c1o3koe3hsp19761ep14.jpg"

One way I can do this is using jQuery to find all <img> tags with a word 'plupload' in their src attribute , and then changing that attribute with full URL. But, it will slow down display a lot. Any other ideas using Drupal module or custom coding?

1 Answer 1

1

You can probably accomplish that with a custom filter involving a regular expression using either Flexfilter or Custom filter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.