Marcus Schmidke:
but the result is having the absolute image path in the journal article object
Now I've found a solution for this, but I am not sure if it is a bad hack.
It took the following steps:
Once again, I've changed ImageCommandReceiver.
fileEl.setAttribute("size", getSize(image.getSize()));
fileEl.setAttribute(
"url", "image/image_gallery?img_id=" + image.getImageId());
Actually, yet the only difference to the original version is the removed slash at the beginning of the url.
Then, I've changed the fckconfig.js to have a BaseHref:
FCKConfig.BaseHref = 'http://localhost:8080/mycontext/' ;
(Perhaps this could be coded in some dynamic way sice it's JavaScript). With these changes, the editor works fine, and the URLs in the journal database are relative to the context root.
Lastly, I had to write another TransformerListener and appended it to the journal.transformer.listener property containing code like the following:
@Override
public String onXml(String s) {
StringBuffer r=new StringBuffer(s.length());
if (s!=null) {
String context_root=PropsUtil.get(PropsUtil.PORTAL_CTX);
int start=0;
int pos;
while (start<s.length()) {
pos=s.indexOf("src=\"image/",start);
if (pos>=0) {
r.append(s.substring(start,pos));
r.append("src=\"");
r.append(context_root);
r.append("/");
start=pos+5;
} else break;
}
r.append(s.substring(start));
}
return r.toString();
}
Please sign in to flag this as inappropriate.