Certain drupal hooks within a custom module breaks Focal Point/Crop API

Created on 26 July 2023, 11 months ago
Updated 4 October 2023, 9 months ago

Problem/Motivation

Creating a custom module that uses 'node_insert', 'form_alter' and other related hooks break Focal Point preview. Issue is either with Focal Point (issue opened there as well) or with Crop API.

Steps to reproduce

Enable Focal Point, Crop API, and create and enable a simple custom module using 'node_insert' or 'form_alter' 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 this module and then upload any image using focal point. The preview is broken sitewide (see screenshot)
Issue present on d9 and d10, various versions of both Focal Point and Crop API.

Proposed resolution

This is a major issue that needs to be fixed, prevents creating custom modules with specific hooks.

Remaining tasks

Fix bug

User interface changes

Unsure, bug fix

API changes

Bug fix

Data model changes

Bug fix

πŸ› Bug report
Status

Closed: works as designed

Version

2.3

Component

Code

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
  • Status changed to Closed: works as designed 9 months 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.69.0 2024