I made changes to imagepicker_insert_template.txt as described in the readme. PHP function imagepicker_get_insert_template() read the file just fine, and put the content in JS settings. imagepicker_iframe.js read the template from Drupal.settings. However, the template wasn't used.
I think the problem is in imagepicker_iframe.js, around line 259:
Line 221:
imgpImageElement = '<img src="' + imgpImagePath + '" alt="' + ...
Line 239: imgpInsertion = imgpImageElement;
Line 259:
if (imgpForm.desc.checked) {
imgpTemplate = imgpTemplate.replace("__TITLE__", imgpImageTitle);
imgpTemplate = imgpTemplate.replace("__INSERT__", imgpInsertion);
imgpInsertion = imgpTemplate.replace("__DESC__", imgpImageDesc);
}
The variable imgpInsertion is the one that is output (on line 300 for CKEditor). The template isn't used, unless the desc checkbox is checked. If the checkbox isn't checked, the browser gets the vanilla imgpInsertion set on line 221, rather than the templated content.
I'm not sure what the proper fix is. Perhaps do line 261 always, and lines 260 and 262 depending on whether there is a title, and/or desc is checked. But this may be wrong - I'm not sure how it interacts with the switch statement from lines 237 to 257.
Cool module. My favorite for image handling, other than this problem. Thnx for the code. You rock!
Kieran
Comments
Comment #1
hutch commentedThe purpose of the "Show Description" checkbox is as its name suggests, to regulate wether or not the Title and Description are added to the output. If you have not used imagepicker_insert_template.txt then a default is used, see imagepicker.functions.inc line 3084 function imagepicker_get_insert_template().
If you do not check the "Show Description" checkbox then the templating method is not used, that is by design.
If you want to roll your own imagepicker_iframe.js just copy it to another file (eg imagepicker_iframe_bespoke.js) and point Imagepicker to the new file by setting the javascript path under admin/config/media/imagepicker, at the bottom of the form.
Your bespoke javascript file will be used instead.
For best results use the current dev version, it has a few fixes in it. Remember to flush the cache after installing it, there are some theme changes.
If you want to change the way the "img" html element behaves you can tweak the css class "imgp_img" in your theme css.