Last active
February 22, 2018 21:51
-
-
Save rjesh-git/aee24ffbbe5c8e5e32ed8f3b37b16057 to your computer and use it in GitHub Desktop.
Upload Image from CEWP/Script Editor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.min.js"></script> | |
<script type="text/javascript"> | |
var ShowInsertImage = function (ctlId) { | |
var dOpt = { | |
url: imagesPath, | |
args: null, dialogReturnValueCallback: function callback(status, result) { | |
console.log('new file uploaded here:'+result.newFileUrl); | |
$('#container').append( '<br/><img src="'+result.newFileUrl+'" height="200" width="200">' ); | |
}, | |
showMaximized: false, showClose: true, autoSize: true, title: 'Upload image'}; | |
SP.SOD.executeFunc('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', function () { SP.UI.ModalDialog.showModalDialog(dOpt); }); | |
} | |
var imagesPath = 'https:\u002f\u002fYOURTENANT.sharepoint.com\u002fsites\u002fYOURSITE\u002f_layouts\u002f15\u002fupload.aspx?RootFolder=\u002fsites\u002fYOURSITE\u002fPublishingImages\u0026List=LIST_ID\u0026'; | |
</script> | |
<div id='container'> | |
<button onclick="ShowInsertImage('InsertImageTest');return(false);">Add Image</button> | |
</div> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment