Get URL of first image file embedded in specific Rich Text field

// Get URL of first image file embedded in specific Rich Text field
// Param:
// doc: target notes document
// strImgField: rich text field name which contains the embedded image 
function getAttachmentImageURL(doc:NotesDocument, strImgField:String){
	var strRet = "";
		var rtItem:NotesRichTextItem  = doc.getFirstItem(strImgField);
		if(rtItem !== null){
			var attachmentName = rtItem.getEmbeddedObjects().get(0).getName();	// Get first attachment image
			var webScheme = facesContext.getExternalContext().getRequest().getScheme();
			var webSrvName = facesContext.getExternalContext().getRequest().getServerName();
			var webDbName = facesContext.getExternalContext().getRequest().getContextPath();
			var url = webScheme+"://"+webSrvName+webDbName+"/xsp/.ibmmodres/domino/OpenAttachment/"+webDbName;
			strRet = url+'/'+doc.getUniversalID()+'/'+strImgField+'/'+attachmentName;
	return strRet

xpages, rich text field, embedded image

JavaScript (Server)
Kazunori Tatsuki
August 21, 2015 5:05 AM

All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.

No comments yetLogin first to comment...