Default code for insert image is:

php:
$imce_url = function_exists('imce_access') && imce_access() ? url('imce') : '';

return "js:
var B = eDefBrowseButton('$imce_url', 'attr_src', 'Browse', 'image');
var form = [
 {name: 'src', title: 'Image URL', suffix: B},
 {name: 'width', title: 'Width x Height', suffix: ' x ', getnext: true, attributes: {size: 3}},
 {name: 'height', attributes: {size: 3}},
 {name: 'alt', title: 'Alternative text'}
];
eDefTagDialog('img', form, 'Insert/edit image', 'OK');
";

These functions generate an html-code like this:
<img src="$form[name]" width="$form[width]" height="$form[height]" alt="$form[alt]" />

Is it possible insert an additional div-tag outside img-tag? I need this html-code:
<span><img src="$form[name]" width="$form[width]" height="$form[height]" alt="$form[alt]" />$form[alt]</span>

Thanks for help.

Comments

ufku’s picture

php:
$imce_url = function_exists('imce_access') && imce_access() ? url('imce') : '';

return "js:
var B = eDefBrowseButton('$imce_url', 'attr_src', 'Browse', 'image');
var form = [
{name: 'src', title: 'Image URL', suffix: B},
{name: 'width', title: 'Width x Height', suffix: ' x ', getnext: true, attributes: {size: 3}},
{name: 'height', attributes: {size: 3}},
{name: 'alt', title: 'Alternative text'}
];
//tell bue that the form will be handled by wrapMyImgCode function.
eDefTagDialog('img', form, 'Insert/edit image', 'OK', 'wrapMyImgCode');

//define your custom submit handler.
wrapMyImgCode = function(tag, form) {
  //let the default handler insert the image code
  eDefTagInsert(tag, form);
  //let's wrap the img code
  BUE.active.tagSelection('<span>', form.elements.attr_alt.value +'</span>');
};

";

dicreat’s picture

Status: Active » Fixed

Thanks, it's work!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.