Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

主题是否能集成,wp媒体库上传图片,优化为只见当前文章图片 #476

Closed
yaociyuan opened this issue Feb 6, 2022 · 2 comments

Comments

@yaociyuan
Copy link

使用 WordPress 的朋友应该都清楚,特别是喜欢图文并茂的网站,肯定离不开的就是 WordPress 文章编辑页面的“添加媒体”按钮,每次点击就能弹出一个插入多媒体的界面,然后页面默认就会列举加载所有最近的媒体库上传的文件,从而文件过多过大的请求下载,就可能造成页面的卡顿或假死,同时也会造成服务器带宽资源的浪费,严重影响网站内容的编辑和效率。

代码部分

//WordPress “添加媒体”文件时只显示上传到当前文章的附件
//add_action( 'wp_footer', 'fanly_mediapanel_lock_uploaded' );//让前台编辑器也生效
add_action( 'admin_footer-post-new.php', 'fanly_mediapanel_lock_uploaded' );
add_action( 'admin_footer-post.php', 'fanly_mediapanel_lock_uploaded' );
function fanly_mediapanel_lock_uploaded() {
echo '<script type="text/javascript">var $i=0;jQuery(document).on("DOMNodeInserted", function(){if(jQuery("#media-attachment-filters").length>0&&$i==0){jQuery('select.attachment-filters [value="uploaded"]').attr('selected',true).parent().trigger('change');$i++;}});</script>';
}

@seatonjiang
Copy link
Owner

收到,我这里看一下。

@seatonjiang
Copy link
Owner

功能已经添加了,下个版本更新即可。

image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants