Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-78805

html Mustache Template to image generation api

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • Future Dev
    • Course

      This is to support the open graph spec in MDL-78804

      There is a need to flexibly create static images which contain various bits of text or images for social sharing and possible other purposes. This proposes to create a general purpose image generation service which uses mustache templates to create mini chunks of html which are then rendered server side into a flat image for this purpose.

      There are 2 main candidates for exactly how the html is rendered:

      1. We use a headless browser service, this is how it is usually done in the wild and means the full css of the sites theme can be used in the image which has pros and cons. The big con technically is it is another full service which isn't easily bundled in core by default and we really want this service to have a default implementation shipped in core
      2. We can render basic html using tcpdf and then export into an image, similar to how custom certificates are rendered. The complexity of the things we want to render is probably fine for this approach and the libraries are already in core and used in other places.

      By using templates it makes it easy for themes to override these image templates.

      There will very likely be some relationship with the image service api idea in MDL-72140

      https://rkrknowledge.com/convert-html-to-png-in-laravel-with-tcpdf-and-imagemagick/

      Similar services and examples:

      Github's internal service:

      https://github.blog/2021-06-22-framework-building-open-graph-images/

      Vercel node.js / puppeteer / Chromium:

      https://vercel.com/docs/concepts/functions/edge-functions/og-image-generation

      https://vercel.com/blog/introducing-vercel-og-image-generation-fast-dynamic-social-card-images

       

       

            Unassigned Unassigned
            brendanheywood Brendan Heywood
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.