1414WYMeditor . editor . prototype . image_upload = function ( ) {
1515 var wym = this ;
1616 var uploadUrl = wym . _options . dialogImageUploadUrl ;
17+
18+ wym . _options . attributionImgAttribute = 'data-attribution' ;
19+ wym . _options . attributionSelector = '.wym_attribution' ;
20+
1721 // Check the options
1822 if ( uploadUrl == undefined ) {
1923 WYMeditor . console . warn (
@@ -29,7 +33,10 @@ WYMeditor.editor.prototype.image_upload = function() {
2933 orig . call ( this , wDialog ) ;
3034 var wym = this ,
3135 doc = wDialog . document ,
32- options = wym . _options ;
36+ options = wym . _options ,
37+ selectedImage = wym . getSelectedImage ( ) ;
38+
39+ jQuery ( options . attributionSelector , doc ) . val ( jQuery ( selectedImage ) . attr ( options . attributionImgAttribute ) ) ;
3340
3441 var oldSubmitLabel = jQuery ( "form#image_upload_form .submit" , doc ) . val ( ) ;
3542 // WYMEditor automatically locks onto any form here, so remove the binding.
@@ -47,12 +54,37 @@ WYMeditor.editor.prototype.image_upload = function() {
4754 } else {
4855 jQuery ( options . srcSelector , doc ) . val ( response . thumbUrl ) ;
4956 jQuery ( options . altSelector , doc ) . val ( response . original_filename ) ;
57+ jQuery ( options . attributionSelector , doc ) . val ( response . attribution ) ;
5058 }
5159 jQuery ( "form#image_upload_form .submit" , doc ) . val ( oldSubmitLabel ) ;
5260 }
5361 } )
5462 } ;
5563
64+ d . submitHandler = function ( wDialog ) {
65+ var wym = this ,
66+ options = wym . _options ,
67+ imgAttrs ,
68+ selectedImage = wym . getSelectedImage ( ) ;
69+
70+ imgAttrs = {
71+ src : jQuery ( options . srcSelector , wDialog . document ) . val ( ) ,
72+ title : jQuery ( options . titleSelector , wDialog . document ) . val ( ) ,
73+ alt : jQuery ( options . altSelector , wDialog . document ) . val ( ) ,
74+ } ;
75+ imgAttrs [ options . attributionImgAttribute ] = jQuery ( options . attributionSelector , wDialog . document ) . val ( ) ;
76+
77+ wym . focusOnDocument ( ) ;
78+
79+ if ( selectedImage ) {
80+ wym . _updateImageAttrs ( selectedImage , imgAttrs ) ;
81+ wym . registerModification ( ) ;
82+ } else {
83+ wym . insertImage ( imgAttrs ) ;
84+ }
85+ wDialog . close ( ) ;
86+ }
87+
5688 // Put together the whole dialog script
5789 wym . _options . dialogImageHtml = String ( ) +
5890 '<body class="wym_dialog wym_dialog_image">' +
@@ -95,6 +127,10 @@ WYMeditor.editor.prototype.image_upload = function() {
95127 '<label>{Title}</label>' +
96128 '<input type="text" class="wym_title" value="" size="40" />' +
97129 '</div>' +
130+ '<div class="row">' +
131+ '<label>{Attribution}</label>' +
132+ '<input type="text" class="wym_attribution" value="" size="40" placeholder="{Attribution_placeholder}" />' +
133+ '</div>' +
98134 '<div class="row row-indent">' +
99135 '<input class="wym_submit" type="submit" ' + 'value="{Submit}" />' +
100136 '<input class="wym_cancel" type="button" ' + 'value="{Cancel}" />' +
0 commit comments