【发布时间】:2018-06-21 13:00:54
【问题描述】:
我在我的 wordpress 管理员中为自己构建了一个自定义选项页面。在其中,我有一些“媒体”选择器按钮,它们使用以下内容:
jQuery( document ).ready( function( $ ) {
// pop the media box
$('.gyo_upload').on( 'click', function( e ) {
e.preventDefault();
var send_attachment_bkp = wp.media.editor.send.attachment;
var $button = $( this );
wp.media.editor.send.attachment = function( props, attachment ) {
alert(props.library);
var $_which = $button.data( 'which' );
$( '#img_' + $_which ).attr( 'src', attachment.url ).css( 'width', 'auto' );
$( '#' + $_which ).val( attachment.url );
wp.media.editor.send.attachment = send_attachment_bkp;
}
wp.media.editor.open( $button );
return false;
} );
$('.remove_image_button').click(function() {
var answer = confirm('Are you sure?');
if (answer == true) {
var src = $(this).parent().prev().attr('data-src');
var $this = $( this );
var $_which = $this.data( 'which' );
$( '#img_' + $_which ).attr('src', '');
$( '#' + $_which ).val('');
}
return false;
});
} );
虽然效果很好,但我还没有找到如何将其限制为仅显示图像,而是显示完整的媒体范围。
如何强制它只使用/显示图像?
【问题讨论】:
-
你能添加同一个媒体窗口的“之前”状态吗? (当您删除您添加的所有自定义代码时)
-
嗯?请解释一下你的意思
标签: javascript jquery wordpress wordpress-theming