Since 4.x release, hook_file_url_alter() is no longer called, breaking several modules
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3391254. -->
Reported by: [driskell](https://www.drupal.org/user/3075367)
Related to !23
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Previously in the 8.x-3.x code releases, CDN was using hook_file_url_alter to alter the URL for the CDN. This was then fully compatible with other modules using hook_file_url_alter, such as Crop API.</p>
<p>Since 4.0, the hook_file_url_alter approach was removed and instead, the FileUrlGenerator is decorated. However, the new FileUrlGenerator does not call hook_file_url_alter for any URL generated by the CDN module. This breaks other modules such as Crop API, which add additional query parameters to the URL to ensure that when a crop is changed for an image, the CDN URL is changed accordingly.</p>
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<p>These are fairly abstract as I didn't have time to produce a specific scenario</p>
<p>1. Implement a custom module that implements hook_file_url_alter<br>
2. Test generating a file URL - this hook is called<br>
3. Install and configure the CDN module<br>
4. Test generating a file URL - the hook is no longer called</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>Implement hook_file_url_alter in the CDN module's FileUrlGenerator prior to processing the incoming URI, in the same way that the core FileUrlGenerator does.</p>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<p>1. Implement hook_file_url_alter</p>
<h3 id="summary-ui-changes">User interface changes</h3>
<p>None</p>
<h3 id="summary-api-changes">API changes</h3>
<p>None - fixes an API - notably hook_file_url_alter</p>
<h3 id="summary-data-model-changes">Data model changes</h3>
<p>None</p>
> Related issue: [Issue #499156](https://www.drupal.org/node/499156)
> Related issue: [Issue #3391551](https://www.drupal.org/node/3391551)
issue