@@ -29,7 +29,10 @@ WYMeditor.editor.prototype.image_upload = function() {
2929 orig . call ( this , wDialog ) ;
3030 var wym = this ,
3131 doc = wDialog . document ,
32- options = wym . _options ;
32+ options = wym . _options ,
33+ selectedImage = wym . getSelectedImage ( ) ;
34+
35+ jQuery ( options . attributionSelector , doc ) . val ( jQuery ( selectedImage ) . attr ( options . attributionImgAttribute ) ) ;
3336
3437 var oldSubmitLabel = jQuery ( "form#image_upload_form .submit" , doc ) . val ( ) ;
3538 // WYMEditor automatically locks onto any form here, so remove the binding.
@@ -47,12 +50,40 @@ WYMeditor.editor.prototype.image_upload = function() {
4750 } else {
4851 jQuery ( options . srcSelector , doc ) . val ( response . thumbUrl ) ;
4952 jQuery ( options . altSelector , doc ) . val ( response . original_filename ) ;
53+ jQuery ( options . attributionSelector , doc ) . val ( response . attribution ) ;
5054 }
5155 jQuery ( "form#image_upload_form .submit" , doc ) . val ( oldSubmitLabel ) ;
5256 }
5357 } )
5458 } ;
5559
60+ d . submitHandler = function ( wDialog ) {
61+ var wym = this ,
62+ options = wym . _options ,
63+ imgAttrs ,
64+ selectedImage = wym . getSelectedImage ( ) ;
65+
66+ imgAttrs = {
67+ src : jQuery ( options . srcSelector , wDialog . document ) . val ( ) ,
68+ title : jQuery ( options . titleSelector , wDialog . document ) . val ( ) ,
69+ alt : jQuery ( options . altSelector , wDialog . document ) . val ( ) ,
70+ } ;
71+ imgAttrs [ options . attributionImgAttribute ] = jQuery ( options . attributionSelector , wDialog . document ) . val ( ) ;
72+
73+ wym . focusOnDocument ( ) ;
74+
75+ if ( selectedImage ) {
76+ wym . _updateImageAttrs ( selectedImage , imgAttrs ) ;
77+ wym . registerModification ( ) ;
78+ } else {
79+ wym . insertImage ( imgAttrs ) ;
80+ }
81+ wDialog . close ( ) ;
82+ }
83+
84+ wym . _options . attributionImgAttribute = 'data-attribution' ;
85+ wym . _options . attributionSelector = '.wym_attribution' ;
86+
5687 // Put together the whole dialog script
5788 wym . _options . dialogImageHtml = String ( ) +
5889 '<body class="wym_dialog wym_dialog_image">' +
@@ -95,6 +126,10 @@ WYMeditor.editor.prototype.image_upload = function() {
95126 '<label>{Title}</label>' +
96127 '<input type="text" class="wym_title" value="" size="40" />' +
97128 '</div>' +
129+ '<div class="row">' +
130+ '<label>{Attribution}</label>' +
131+ '<input type="text" class="wym_attribution" value="" size="40" placeholder="{Attribution_placeholder}" />' +
132+ '</div>' +
98133 '<div class="row row-indent">' +
99134 '<input class="wym_submit" type="submit" ' + 'value="{Submit}" />' +
100135 '<input class="wym_cancel" type="button" ' + 'value="{Cancel}" />' +
0 commit comments