So I encountered what I consider to be a bug, although I can foresee an argument to the contrary, that when an entity has a Media field attached to it, and say for some reason al Image style derivatives had been deleted, and the entity with the Media field is updated, an Image attached as Media does not trigger the regeneration of it's derivatives.

The reason this happens, and the reason that there is partial Media support, is that hook_entity_insert() looks for Image fields, of which a Media field is not, but a Media fields entity may have an Image field, so when creating a Node with an Image Media field a Media entity is saved triggering the generation of all necessary derivatives, but unless the Media's entity is updated, the derivatives won't be regenerated again.

While I don't like give modules special treatment, I do think there is a case for doing so here.

Open to thoughts, but will likely provide a patch quite soon.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Deciphered’s picture

Status: Active » Needs review
FileSize
3.6 KB

Attached patch adds support for Media fields. I considered adding support for when editing the File entity directly (as it doesn't work as I expected it would), but I figured this would be enough for the time being.

I would think that the code could be improved as well, as quite similar to the Image fields integration, but one step at a time.

mikeytown2’s picture

Status: Needs review » Fixed
FileSize
3.6 KB

Thanks for the patch :)
I changed a couple things around and this is the patch that has been committed.

mikeytown2’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.