Problem/Motivation
I am attempting to enable a custom module, fairly simple module that uses hook 'node_insert". When the module is enabled, the focal point preview breaks and does not load the image at all. This issue is present on all Content types.
Similar to a second issue I opened months ago:
https://www.drupal.org/project/focal_point/issues/3307345
π
Focal Point Preview broken on forms altered with form_alter hooks
Closed: works as designed
Steps to reproduce
Create a simple custom module using 'node_insert' hook, such as:
.module file:
function ucb_article_author_node_insert(EntityInterface $node) {
// Check if the inserted entity is of the 'Person Page' content type.
if ($node->getEntityTypeId() === 'node' && $node->bundle() === 'ucb_person') {
// Extract the first and last name from the entity's title.
$title = $node->getTitle();
// Create a taxonomy term using the extracted name.
$term = Term::create([
'vid' => 'byline',
'name' => $title,
'field_author_person_page' => [
'target_id' => $node->id(),
],
]);
// Save the taxonomy term to update the entity reference field.
$term->save();
}
}
Enable the module and then add in media on any page. You will see the focal point preview image is broken, the image fails to load. See screenshot.
Proposed resolution
Bug fix. This seems to be an issue with certain drupal hooks.
Remaining tasks
Bug fix
User interface changes
form_alter hooks and node_insert hooks appear to be breaking the preview, this bug needs to be addressed
API changes
n/a
Data model changes
n/a