Just use a dataview. See the documentation here: https://docs.mendix.com/refguide/document-templates#1-introduction the part 4.2 dynamic image.
Regards,
Ronald