Can’t add images on options page. The field is present but can’t select anything.
Adding an Image Field to to an Options page gives the error:
TypeError: wp.media.view.settings.post is undefined
from:
media-audiovideo.min.js?ver=6.0.2:2
Removing the Image field clears the error.
Have you tried deactivating other plugins?
Are you using gubenberg or classic editor?
Can you give a more detailed JS error report?
Deactivated all other plugins (except Timber required for my theme) and error persist.
Using Gutenberg editor.
I was able to narrow down what was causing the issue:
I have a script enqueued in the admin
wp_enqueue_script('admin', get_template_directory_uri() . '/assets/src/js/admin.js',
array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-plugins', 'wp-components', 'wp-edit-post', 'wp-api', 'wp-editor', 'wp-hooks', 'lodash', )
, '1', false );
When I remove the following dependencies the error goes away
'wp-components', 'wp-edit-post', 'wp-api', 'wp-editor', 'wp-hooks'