Skip to content

Commit e0bc1c6

Browse files
committed
gw-rich-text-html-fields.php: Added image upload capabilities.
1 parent 355facd commit e0bc1c6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

gravity-forms/gw-rich-text-html-fields.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,15 @@
8686
} );
8787

8888
frame.on('select', function() {
89-
var attachment = frame.state().get('selection').first().toJSON();
90-
editor.insertContent('<img src="' + attachment.url + '" alt="' + attachment.alt + '" />');
89+
var selection = frame.state().get('selection').first();
90+
if (!selection) {
91+
return;
92+
}
93+
94+
var attachment = selection.toJSON();
95+
var url = attachment.url.replace(/"/g, '&quot;');
96+
var alt = (attachment.alt || '').replace(/"/g, '&quot;');
97+
editor.insertContent('<img src="' + url + '" alt="' + alt + '" />');
9198
} );
9299

93100
frame.open();

0 commit comments

Comments
 (0)