delete img src="null" when pressing cancel in image prompt Button Bar
jackmaessen
✭✭✭
I noticed that the embedded plugin Button Bar in 2.1 prompts with clicking on image button and url button.
There is only one thing i find disturbing, that when you press Cancel in the prompt, he returns null in the textarea
img src="null"
So i put an if statement in the case to disable this text:
The original case:
case 'image':
var urlOpts = {};
var thisOpts = $.extend(htmlOpts, {
closetype: 'short'
});
var PromptText = gdn.definition('ButtonBarImageUrl', 'ButtonBar.ImageUrlText');
NewURL = prompt(PromptText);
urlOpts.src = NewURL;
$(TextArea).insertRoundTag('img',thisOpts,urlOpts);
break;
Customized case:
case 'image':
var urlOpts = {};
var thisOpts = $.extend(htmlOpts, {
closetype: 'short'
});
var PromptText = gdn.definition('ButtonBarImageUrl', 'ButtonBar.ImageUrlText');
NewURL = prompt(PromptText);
if(NewURL != null){ // condition added
urlOpts.src = NewURL;
$(TextArea).insertRoundTag('img',thisOpts,urlOpts);
} // end if
break;
Maybe helpfull for other people who wants to disable the
img src="null"
in the textarea when pressing Cancel
Tagged:
2
Comments
It works, thanks!