Skip to content

fix(editor): update asset loading for ACF V3 blocks in editor#499

Open
rsanchez-beapi wants to merge 1 commit into
masterfrom
fix/acf-v3-blocks
Open

fix(editor): update asset loading for ACF V3 blocks in editor#499
rsanchez-beapi wants to merge 1 commit into
masterfrom
fix/acf-v3-blocks

Conversation

@rsanchez-beapi

@rsanchez-beapi rsanchez-beapi commented Jun 25, 2026

Copy link
Copy Markdown

Depuis WordPress 6.3, le canvas de l’éditeur Gutenberg est isolé dans une iframe (iframe[name="editor-canvas"]). Les blocs ACF V3 (blockVersion: 3) y injectent leurs templates PHP de rendu — y compris le markup lazyload ARI — à chaque rafraîchissement de prévisualisation.

Le script editor.js (qui charge lazySizes) était enregistré via enqueue_block_editor_assets, un hook qui ne cible que la coquille admin, en dehors de l’iframe. Résultat : les images .lazyload des blocs ACF V3 restaient invisibles dans l’éditeur jusqu’à une mutation DOM déclenchant lazySizes.

Ce correctif bascule l’enqueue vers enqueue_block_assets, qui s’exécute dans l’iframe et sur le front, avec un garde is_admin() pour éviter de charger le script côté public.

Changements

  • Remplacement du hook enqueue_block_editor_assets par enqueue_block_assets pour le chargement de editor.js
  • Ajout d’un early return is_admin() dans admin_editor_script() (le nouveau hook s’exécute aussi en front)
  • Documentation inline du comportement WP 6.3+ et de l’impact sur les blocs ACF V3 / lazySizes

Note

Medium Risk
Changes when and where editor JS loads in wp-admin and on the front end; incorrect guarding could enqueue admin editor scripts on the front end or miss them in the iframe.

Overview
Editor script loading is moved from enqueue_block_editor_assets to enqueue_block_assets so editor.js (including lazySizes) runs inside the WP 6.3+ editor canvas iframe, where ACF Blocks V3 PHP previews and .lazyload markup actually render.

admin_editor_script() now returns early when ! is_admin() so the same hook does not enqueue that bundle on the public site. Inline comments document why the iframe vs admin-shell split matters for ACF V3 previews.

Reviewed by Cursor Bugbot for commit 87cbed9. Bugbot is set up for automated code reviews on this repo. Configure here.

- Changed the action hook from `enqueue_block_editor_assets` to `enqueue_block_assets` to ensure ACF V3 block previews load correctly within the iframe.
- Added comments to clarify the impact of WP 6.3+ on block rendering and lazy loading of images.
@rsanchez-beapi rsanchez-beapi requested a review from cedric07 June 25, 2026 13:01

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 87cbed9. Configure here.

Comment thread inc/Services/Editor.php
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.

1 participant