Skip to content

Instantly share code, notes, and snippets.

@OlafD
Last active November 28, 2018 16:17
Show Gist options
  • Save OlafD/61c6d21b5b9d1ec054002c49e01e3043 to your computer and use it in GitHub Desktop.
Save OlafD/61c6d21b5b9d1ec054002c49e01e3043 to your computer and use it in GitHub Desktop.
Snippet for a SharePoint Script Editor webpart, to show an image and on a click show the image
<script type="text/javascript">
var dlgOptions;
function setDlgOptions(pictureUrl) {
var htmlFragment = document.createElement("img");
htmlFragment.setAttribute("src", pictureUrl);
htmlFragment.setAttribute("width", "800");
htmlFragment.setAttribute("height", "600");
dlgOptions = {
title: "The Image",
width: 800,
height: 600,
html: htmlFragment,
showClose: true
};
}
</script>
<img src="https://your-tenant.sharepoint.com/sites/img-tester/Shared%20Documents/Sonnenuntergang_mit_Segelschiff.png"
width="400"
height="300"
onclick="setDlgOptions(this.src); SP.UI.ModalDialog.showModalDialog(dlgOptions);">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment