How to add an image?

Internal image

img ~alt:("Ocsigen Logo")
      ~src:(make_uri
              ~service:(Eliom_service.static_dir ())
              ["ocsigen_logo.png"])
    ()

External image

img ~alt:("Ocsigen Logo")
      ~src:(Xml.uri_of_string ("http://website.com/image.png"))
    ()

The function img has 3 parameters:

For an internal image, the file path is generated using the make_uri function. This function creates the relative URL string using the static directory configured in the configuration file and the given list.

For an external image, you must convert the string url into uri using the uri_of_string function. You can also create an external service.

Download full code

Links

◄ Back to the Quick Howto's