Forum OpenACS Development: Re: xowiki javascript "function calc_image_tags_to_wiki_image_links" doesn't do what you'd expect...

....and I have also had to modify the following lines of the calc_wiki_image_links_to_image_tags function that converts the [[my_page/image:my_photo_ext]] link back into an <img> tag so that the editor window can retrieve and display the image in WSIWYG fashion:

    var regex_wikilink = new RegExp('(\\[\\[.*/image:)(.*)(\\]\\])', 'g');
    data = data.replace(regex_wikilink,'<img src="'+pathname+'/file:$2?m=download"  alt="image:$2" type="wikilink"  />');

In context the complete function with adjusted lines is:

function calc_wiki_image_links_to_image_tags (data) {
    var pathname = window.location.pathname;
    pathname = pathname.substr(pathname.lastIndexOf("/")+1,pathname.length)
    console.log('pathname' + pathname);
    pathname = pathname.replace(/:/ig,"%3a");
    var regex_wikilink = new RegExp('(\\[\\[.*/image:)(.*)(\\]\\])', 'g');
    data = data.replace(regex_wikilink,'<img src="'+pathname+'/file:$2?m=download"  alt="image:$2" type="wikilink"  />');
    console.log('data' + data);
    return data
}

It was as if someone had modified the code to create filenames with the page name prefixed to them, but did not adjust the javascript helper functions to match.

It is certainly very helpful that the xowikiimage selector/uploader only displays images that have been uploaded for the specific page you are working on.  Otherwise the number of images in the selector would rapidly become unmanageable.  It may simply be that the Javascript functions were not updated after this refinement was added.

Regards
Richard