Pagefile Metadata

This module allows you to add media metadata information to FieldtypeFile fields and provides access to the metadata via simple API methods/properties.

What it does


This module allows you to add media metadata information to FieldtypeFile fields. Under the hood it uses the PHP library getID3 by James Heinrich and stores the raw data in the fields' filedata property.

getID3 is an open source PHP library for reading and analysing metadata from various types of multimedia files, including audio, video and image files. The library can extract a wide range of information such as title, artist, album, bitrate, playtime, resolution and even technical details about the file's encoding and format. It supports a wide range of formats including MP3, MP4, AVI, FLAC, OGG and more.

One of the motivations for developing this module was the need to know the aspect ratio of self-hosted mp4 videos in order to avoid layout shifts during rendering. However, this use case is very specific and the idea of this module is to make the huge amount of metadata provided by getID3 accessible via simple apis. The module comes with some video specific functions that give access to width, height, aspect and type, but this functionality can easily be extended by hooking into ___getMetadata and returning your own formatted data.

Features


  • Analyse and store metadata information
  • Field based opt-in for FieldtypeFile files
  • Access metadata via api methods
  • Add metadata information to the field rendering in the backend

Install


  1. Copy the module files to /site/modules/PagefileMetadata/
  2. Run composer install in module directory.
    composer install

Edit Field settings

Fields > yourFieldtypeFile > Details Check the checkbox Enable analyze and store metadata to enable the feature for a specific field

API


Returns full metadata as array

/** @var array */
$file->metadata or $file->metadata()

A few video specific properties are available directly via function params

/** @var int */
$file->metadata('width')

/** @var int */
$file->metadata('height')

/** @var int */
$file->metadata('aspect')

Backend field rendering


Add metadata information to the field rendering in the backend by hooking into ___renderItemInfo. image

Todos


  • Add process in backend to regenerateMetadata

Feedback


If you have any feedback, please reach out to us at code@neuerituale.com or create an issue in the github project.

More modules by Neue Rituale

  • FieldtypeOembed (oEmbed)

    Collect and store oEmbed data
  • PageTable Next

    The module provides a list of PageTable based content elements. It enables the backend user to easily create, publish, move, delete, copy and paste content elements.
  • Process Cron Jobs

    Manages the execution of CronJobs
  • Pagefile Metadata

    This module allows you to add media metadata information to FieldtypeFile fields and provides access to the metadata via simple API methods/properties.
  • Text Synthesis

    Syntheses text fields with the Google Cloud Api Text2Speech
  • FieldtypeGeocoder

    Retrieve, collect and store geolocation data from external geocoding services
  • Podcast Subscriptions

    Subscribe Podcast RSS feed and save episodes as new page

All modules by Neue Rituale

Install and use modules at your own risk. Always have a site and database backup before installing new modules.