H5P file management

otacke's picture

I've been tampering with H5P's file management in h5p-php-editor-library, and it seems that information about media files consists of a path, a mime type and copyright information. Where's this structure defined? I managed to e.g. store additional information by adding fields to a file object inside h5peditor-av.js. I can see it inside the content.json file inside the H5P file that I can download. However it seems that this information isn't loaded or gets lost on its way back to the content type editor. Any hint will probably save me some time :-)

icc's picture

When you view H5P content for the first time it's filtered against the fields defined in semantics. The image fields are validated using the H5PContentValidator class's validateImage() which really just adds a few allowed properties and let _validateFilelike() do the rest.

To allow for custom properties they have to be added by setting the "extraAttributes": ["myCustomProp"] property in semantics.json. Though, be aware that it doesn't look like the values entered for custom attributes are validated.

otacke's picture

It's really that easy? Maybe you could add this info to the semantics specification. Well, and I tend to validate and sanitize exessively anyway ...

otacke's picture

Hmm, I still didn't figure it out, I fear. I'll try again on Sunday when I have some more time.

otacke's picture

Had some time to sit down ... It works. Thanks!