AdvancedCustomFields / AdvancedCustomFields/acf
Button "Add image" of image field throw error on option page
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:
- Create an option page "option"
- Create an acf field group with an image field inside
- Associate the field group to the option page
- Go to the option page and click on "Add image" button
- 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
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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