Focal Point preview fails to load images sitewide with custom module using hook node_insert

Created on 25 July 2023, over 1 year ago
Updated 4 October 2023, over 1 year ago

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

πŸ› Bug report
Status

Closed: works as designed

Version

2.0

Component

Media Integration

Created by

πŸ‡ΊπŸ‡ΈUnited States pabr5825

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @pabr5825
  • πŸ‡ΊπŸ‡ΈUnited States pabr5825

    Just tested again on a vanilla D10 install, only added modules focal point v 2.0 and the crop api v8.x-2.3, along with the custom module.
    Still have missing images in the focal point preview, see secondary screenshot (2023-07-26)

  • πŸ‡ΊπŸ‡ΈUnited States pabr5825
  • Status changed to Closed: works as designed over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States pabr5825

    We figured out this issue, it was related to Symfony's BinaryFineResponse rather than Focal Point, Crop API, or Drupal. Our closing php tag was causing additional lines to be injected into the output. Closing issue.

Production build 0.71.5 2024