H5P nodes seem to be cloneable. That is great. Question, are the file and images resources for a cloned H5P node also properly duplicated? That is our separate copies of the file and image made for the new node. Do you use the standard file field API to accomplish that?

Comments

webservant316 created an issue.

falcon’s picture

They are indeed cloneable, and images etc. are cloned as well, but not using the file field api. A consequence of this is that the users quotas are currently not updated when cloning H5Ps.

webservant316’s picture

How are the images cloned? Are they serialized into the node? Or do they exists as files that you copy with a clone hook?

falcon’s picture

All files belonging to a node is kept in a folder. It is in sites/default/files/h5p/content/[content-id] IIRC. That folder is copied.

webservant316’s picture

okay thanks!

webservant316’s picture

Okay will this then work to programmatically copy any H5P node?

$node = node_load($nid);
$node->nid = 0;
$node->is_new = TRUE;
$node->validated = TRUE;
$nid2 = node_save($node);
copyr("public://h5p/content/$nid", "public://h5p/content/$nid2");

Or what do I need to add?

falcon’s picture

It probably should. I'm not sure, and I don't have the time to test it :/

webservant316’s picture

It appears to work in my use case, but I am concerned that I might be missing something. If you get time I would appreciate your giving it some thought.