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:

  • alt: A description of the image
  • src: the URL of the image
  • unit

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

Warning: This third party code may be outdated. Please notify the author is something is broken, or do a pull request on github.

Links