This control is view-only. It is not interactive.
Images are currently loaded via the Graph API. This is quite inefficient and will be replaced with a more robust system in the future. For now, please be mindful with image sizes.
Image()

Example

from mirmod.controls import Image
from mirmod import miranda
import json
import base64

@wob.init()
def init(self):
	self.image_path = None

@wob.receiver("value", "Image Path")
def set_image(self, i):
	self.image_path = i

@wob.receiver("state","image",control=Image(),hidden=True,connectable=False)
def get_image(self,plotly_data):
	pass

@wob.execute()
def execute(self):
	# Load image from disk
	image = None
	if self.image_path:
		with open(self.image_path, "rb") as image_file:
			image = image_file.read()
	
	# generate base64 url
	image = "data:image/png;base64," + base64.b64encode(image).decode("utf-8")

	ecx = miranda.get_execution_context()
	ob = ecx.get_current_wob()
	sc = ecx.get_security_context()

	miranda.update_api(
		sc, ob,
		"RECEIVER", "image", "state",
		value=image, connectable=False, hidden=True
	)
	miranda.notify_gui(sc, json.dumps({
		"action": "update[VIEW]",
		"data": { "id": ob.id, "metadata_id" : ob.metadata_id }
	}))