1

We have few WordPress sites with custom themes where new posts are added very frequently (more than 200 posts a day) so we are trying to be as efficient as possible. I tried to google for a solution but could not find an answer on this topic.

When the Post author clicks on Set Featured Image we want them to directly show them the Feature image uploader window since 99% of the time, we have different feature images for each post.

Upload File

4
  • Please edit your question to include any code samples you've tried, even if they didn't work. As currently written, this question doesn't fit well in a WordPress development Q&A site.
    – Pat J
    Jul 1 '21 at 0:56
  • @PatJ As I mentioned in my post, I could not find any code sample or any other related discussion while Googling. All the results are about beginner tutorials about "How to set feature image". Jul 2 '21 at 0:07
  • Custom bookmarklets javascript:!function(){...code that clicks on buttons/links and makes some checks...}(); can sometimes do quick & dirty wonders with e.g. custom shortcut keys browser extensions :-)
    – birgire
    Jul 5 '21 at 15:18
  • @birgire We have few staffs working remotely. It may work for individuals but not for mid/large scale. Jul 6 '21 at 7:30
2
+50

WordPress exposes media upload component globally, as well the featured image modal with wp.media.featuredImage so developers can interact with it.

FeaturedImage component uses the wp.media.frame which is a Backbone component, which has custom event attached to it.

There's not much documentation on it, you can check the source here.

You can use the following snippet to achieve your needs. It's uses the open event on media frame and set's content mode to upload, the default mode is browse.

function wpse_391259_init_featured_uploader_tab() {
    $script = <<<JSS
    (function (){
        var frame = wp.media.featuredImage.frame();
        frame.on( 'open',function() {
            frame.content.mode('upload')
        });
    })();
JSS;

    wp_add_inline_script( 'media-editor', $script );
}

add_action( 'wp_enqueue_media', 'wpse_391259_init_featured_uploader_tab' );
1
  • Thanks for the answer. It works. This one less click is going to save so much time in the long run. I am surprised this hasn't been discussed that much. Jul 6 '21 at 7:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.