Patterns content-1 and features-2 request missing media 108–110 (404s in the editor)

Aperta Adatta ai principianti
#30 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
84/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
php, wordpress
Ambito
frontend

Direzione di ricerca

Apri inc/patterns/layout/content-1.php (blocchi Cover alle righe 62, 74, 120) e inc/patterns/layout/features-2.php (blocchi Image alle righe 56, 70), ed elimina gli attributi "id" rimasti, oltre a qualsiasi classe wp-image-<id> sui blocchi Image, mantenendo gli URL di Assets_Manager::get_image_url(). Leggi prima #3 per vedere perché gli URL sono stati ricablati. Fatto significa che la Front Page del Site Editor e le anteprime dell’inseritore si caricano senza richieste a /wp-json/wp/v2/media/108–110 nella scheda Network.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
Description

Two of the theme's patterns point at images by attachment ID from the site they were made on. On any other site those attachments don't exist, so whenever the editor shows these patterns it asks for them and gets 404 (Not Found) in the browser console. That happens in the Site Editor (the Front Page template uses content-1), in the block inserter's previews, and in the editor.

  • inc/patterns/layout/content-1.php: three Cover blocks with "id":108 (line 62), "id":109 (line 74) and "id":110 (line 120). Their url already comes from Assets_Manager::get_image_url(); only the IDs are left over.
  • inc/patterns/layout/features-2.php: two Image blocks with "id":108 (line 56) and "id":109 (line 70).

The images themselves display, because the URLs point at the theme's own assets/img/ files. But the IDs trigger the failed requests on every site, and on a site that does have attachments 108–110 they would point the blocks at unrelated media from that site's library.

Related: #3, where content-1's images were being wired to Assets_Manager::get_image_url.

Step-by-step reproduction instructions
  1. On any site with Eduacademy 1.0.1 active, open the browser's developer tools (Console and Network tabs).
  2. Go to Appearance → Editor → Templates → Front Page.
  3. Watch the Network tab.

Expected: no failed requests.
Actual: GET /wp-json/wp/v2/media/108, /109 and /110 answer 404, and the console shows three "Failed to load resource" errors. The same happens when inserting the patterns from Patterns → Eduacademy Patterns.

Screenshots, screen recording, code snippet or Help Scout ticket

Fix suggestion: drop the "id" attribute (and the matching wp-image-<id> class on Image blocks, if present) from these five blocks, so they keep only the theme-asset URL.

Found while adding Eduacademy to the WordPress compatibility checks (Codeinwp/qa-compatibility#168). The same happens on every WordPress version tried (7.0.9, 7.1-RC1, 7.1.5).

Environment info

Eduacademy 1.0.1 (built from the v1.0.1 tag), WordPress 7.0.9 / 7.1-RC1 / 7.1.5, PHP 8.3, Chromium.

Is the issue you are reporting a regression

No

Lingua principale
PHP
Stelle
0
Fork
0
Merge medio
22h 12m
PR unite (30g)
6

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Codeinwp/eduacademy

Tutte le issue di Codeinwp/eduacademy

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.