Microdata can be placed in the HTML tags around fields so that the data can be easily extracted into a JSON object. Microdata is very specific about where microdata attributes should be placed for different HTML tags, so sometimes the field formatters need to place the microdata themselves.
In order to enable microdata output for your fields, you have to:
- Enable microdata configuration
Let microdata module know whether your field has microdata integration and/or whether your field has any properties that have microdata integration. Microdata module will then add a form section to the field settings so the user can specify which microdata terms they want to use for the field.
- Place microdata attributes in field formatter
Based on the user's specifications, a microdata attributes array will be attached to the entity. This array is nested by field name. Your field formatter is responsible for placing the field's microdata attributes in the HTML that the formatter returns.
Additionally, you may want to:
- Write automated tests for microdata
These can ensure that your microdata output doesn't break when changes are made to the formatter code.