H5P Guides

Library Definition (library.json)

This page describes which properties that can be used in the library.json file, and which are optional.

Mandatory properties

The library.json file contained with each library contains metadata and dependencies for the library.

The library.json file has similarly to h5p.json several required fields. The following fields are required:

title

Human readable name of the library. May be used in the H5P editor and overviews of installed libraries.

"title": "Fill in the blanks"

machineName

Machine readable name for the library. Same as the folder name used. Consist only of characters, numbers, dashes, and periods. Should start with a character.

"machineName": "H5P.Blanks"

majorVersion

Version major number. (The x in x.y.z). Positive integer.

"majorVersion": 1

minorVersion 

Version minor number. (The y in x.y.z). Neutral or positive integer.

"minorVersion": 0

patchVersion 

Version patch number. (The z in x.y.z). Neutral or positive integer. The system will automatically update to the latest patchVersion installed for all packages that use the library with the same major and minor version number. A new patch version must therefore not change any behavior of the library, only fix errors.

"patchVersion": 42

runnable

Whether or not this library is runnable. If it is runnable the authoring tool will enable authors to create new instances of content using this library. Values are 0 for not runnable and 1 for runnable.

"runnable": 1

Optional properties

Similar to the h5p.json the library.json file has a set of optional fields. The following list is the available optional fields:

coreApi

An object containing keys "majorVersion" and "minorVersion". Specifies the required version of H5P Core API. If not set, v1.0 is assumed, and the library must not use any functionality added in newer versions of H5P Core.

"coreApi": {
  "majorVersion": 1,
  "minorVersion": 5
}

author

The name of the library author.

"author": "Joubel"

license

A code for the content license. The same license codes can be used as in the h5p.json license.

"license": "MIT"

description

Textual description of the library.

"description": "An interactive task for filling in missing words."

preloadedDependencies

Libraries that need to be loaded for this library to work. Specified as a list of objects with machineNamemajorVersion, and minorVersionfor the required libraries.

"preloadedDependencies": [
    {
      "machineName": "FontAwesome",
      "majorVersion": 4,
      "minorVersion": 1
    }
  ]

dynamicDependencies

Libraries that may be loaded dynamically during library execution. Specified as a list of objects like preloadedDependencies above.

"dynamicDependencies": [
    {
      "machineName": "H5P.JoubelUI",
      "majorVersion": 1,
      "minorVersion": 1
    }
  ]

preloadedJs

List of path to the javascript files required for the library. Paths are relative to the library root folder.

"preloadedJs": [
  {
    "path": "js/blanks.js"
  }
]

preloadedCss

List of paths to CSS files to be loaded with the library. Paths are relative to the library root folder.

"preloadedCss": [
  {
    "path": "css/blanks.css"
  }
]

embedTypes

List of possible ways to embed the package in the page. Available values are div and iframe.

"embedTypes": ["div"]

fullscreen

Enables the integrated full-screen button.

"fullscreen": 1

metadataSettings

Disable metadata completely or just hide title field from content type's form.

"metadataSettings": {
    "disable": 0,
    "disableExtraTitleField": 1
  }

Example

{
  "title": "Fill in the blanks",
  "description": "void",
  "machineName": "H5P.Blanks",
  "majorVersion": 1,
  "minorVersion": 0,
  "patchVersion": 46,
  "runnable": 1,
  "author": "Amendor AS",
  "license": "cc-by-sa",
  "coreApi": {
    "majorVersion": 1,
    "minorVersion": 0
  },
  "preloadedCss": [
    {"path": "css/blanks.css"}
  ],
  "preloadedJs": [
    {"path": "js/blanks.js"}
  ],
  "preloadedDependencies": [
    {
      "machineName": "FontAwesome",
      "majorVersion": 3,
      "minorVersion": 1
    }
  ]
}