Bird
0
0

You wrote this code to open the media uploader but it does not open:

medium📝 Debug Q14 of 15
Wordpress - Content Management
You wrote this code to open the media uploader but it does not open:
jQuery(document).ready(function($) {
  const frame = wp.media({ title: 'Choose File' });
  frame.open();
});

What is the most likely reason?
AThe media uploader cannot be opened inside <code>document.ready</code>
BThe <code>frame.open()</code> method is incorrect
CYou forgot to call <code>wp_enqueue_media()</code> to load media scripts
DjQuery is not loaded on the page
Step-by-Step Solution
Solution:
  1. Step 1: Check media scripts loading

    The media uploader requires wp_enqueue_media() to load scripts; without it, wp.media is undefined or non-functional.
  2. Step 2: Evaluate other options

    frame.open() is correct syntax. jQuery is likely loaded if using $ inside document.ready. The uploader can open inside document.ready.
  3. Final Answer:

    You forgot to call wp_enqueue_media() to load media scripts -> Option C
  4. Quick Check:

    Missing wp_enqueue_media() = no media popup [OK]
Quick Trick: Always enqueue media scripts before using wp.media() [OK]
Common Mistakes:
MISTAKES
  • Calling frame.open() incorrectly
  • Assuming jQuery absence causes this
  • Thinking document.ready blocks media popup

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes