To copy an Attachment into an image you need to create a java action.
Just like to Duplicate image of the Community commons
With the following function you can copy the file into a Image
// BEGIN USER CODE
return this.copyFileToImage(this.getContext(), __fileToClone, __cloneTarget, thumbWidth.intValue(), thumbHeight.intValue());
// END USER CODE
// BEGIN EXTRA CODE
private Boolean copyFileToImage(IContext context, IMendixObject toClone, IMendixObject target, int thumbWidth, int thumbHeight) throws Exception {
if (toClone == null || target == null)
throw new Exception("No file to clone or to clone into provided");
MendixBoolean hasContents = (MendixBoolean) toClone.getMember(context, FileDocument.MemberNames.HasContents.toString());
if (!hasContents.getValue(context))
return false;
InputStream inputStream = Core.getFileDocumentContent(context, toClone);
Core.storeImageDocumentContent(context, target, inputStream, thumbWidth, thumbHeight);
return true;
}
// END EXTRA CODE
Eugene
To display an image on a web form - use the image viewer widget, which is one of the 'native' widgets in Mendix. Alternatively, there are a number of widgets in the appstore that will enable you to display (and edit) these images. One that I like is the image carousel which lets you flip through a collection of pictures.
To display a file (like a pdf), you can use the Document Viewer widget from the appstore. This will show the document inside of an embedded frame in your web form. This widget will also display images.
Have fun,
Mike