Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

markconroy
Copy link
Member

Closes #862

What does this change?

I removed the attempt to get the media ID using the non-existent mid field:

$media_id = $file->_referringItem?->getParent()?->getParent()?->getEntity()?->get('mid')?->getString();
$media = $media_id ? Media::load($media_id) : NULL;

Instead, I directly check if the entity is a Media entity:

$entity = $file->_referringItem?->getParent()?->getParent()?->getEntity();
$media = ($entity instanceof \Drupal\media\MediaInterface) ? $entity : NULL;

This change eliminates the need to get the media ID and then load the media entity again. It directly uses the entity if it's already a Media entity, which is more efficient and avoids the error with the non-existent mid field.


Thanks to Big Blue Door for sponsoring my time to work on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

InvalidArgumentException: Field mid is unknown.
1 participant