admin管理员组文章数量:1289582
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.
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.
Share Improve this question asked Jun 30, 2021 at 23:40 Sahriar SaikatSahriar Saikat 1662 silver badges16 bronze badges 4 |1 Answer
Reset to default 2 +50WordPress 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' );
本文标签: post thumbnailsHow do I set quotUpload Imagequot as detault quotSet Featured Imagequot window
版权声明:本文标题:post thumbnails - How do I set "Upload Image" as detault "Set Featured Image" window? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741463944a2380199.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
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 Commented Jul 5, 2021 at 15:18