AdvancedCustomFields / AdvancedCustomFields/acf

Button "Add image" of image field throw error on option page

Open
#929 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
945
Forks
197
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
Button "Add image" of image field isn't working when added on an option page

To Reproduce
Steps to reproduce the behavior:

  1. Create an option page "option"
  2. Create an acf field group with an image field inside
  3. Associate the field group to the option page
  4. Go to the option page and click on "Add image" button
  5. Console is throwing an error :
Uncaught TypeError: Cannot read properties of undefined (reading 'align')
    at n.resetDisplays (media-views.min.js?ver=6.6.2:2:11778)
    at n.initialize (media-views.min.js?ver=6.6.2:2:11016)
    at h.Model (backbone.min.js?ver=1.5.0:2:4722)
    at n.constructor (media-views.min.js?ver=6.6.2:2:17303)
    at new n (backbone.min.js?ver=1.5.0:2:23777)
    at n.addFrameStates (acf-input.min.js?ver=6.3.6:1:83108)
    at n.initialize (acf-input.min.js?ver=6.3.6:1:82354)
    at n.e (acf.min.js?ver=6.3.6:1:3257)
    at acf.Model (acf.min.js?ver=6.3.6:1:3391)
    at n [as constructor] (acf.min.js?ver=6.3.6:1:6558)

Note : I have this behavior on multiple of my websites, but not those in php 7.
Note : The button work wells when the image field is associated to a page, or a post.

Expected behavior
I should be able tu use image field on options pages.

Screenshots or Video
Capture d’écran 2024-09-23 à 14 56 43

Code
acf-export-informations-fields.json
acf-export-option-page.json

Version Information:

  • WordPress Version 6.6.2
  • PHP Version 8.2
  • ACF Version 6.3.6
  • Browser Chrome 128.0.6613.138 or Safari Version 17.1

Additional context

I got just 2 other plugins activated :

  • Imagify 2.2.2
  • WP Migrate 2.6.13

I use with composer :

  • Timber 2.1.0 (twig for WordPress)
  • Palmiak/timber-acf-wp-blocks 1.15

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the provided field and option-page export files using WordPress 6.6.2, PHP 8.2, and ACF 6.3.6, then inspect the error path through media-views.min.js and acf-input.min.js. Compare the image field behavior on an option page with a post or page; done means the Add image button opens the media interface without the undefined align error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, php, wordpress
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.