php – 具有大小选择的WordPress Media Uploader
发布时间:2020-12-13 13:30:21 所属栏目:PHP教程 来源:网络整理
导读:我想在我自己的WordPress插件中添加图像输入. 为此,我使用标准的WordPress媒体上传器,如下所示: var custom_uploader;$('.upload_image_button').click(function(e) { input = $(this); e.preventDefault(); custom_uploader = wp.media.frames.file_frame
我想在我自己的WordPress插件中添加图像输入.
为此,我使用标准的WordPress媒体上传器,如下所示: var custom_uploader; $('.upload_image_button').click(function(e) { input = $(this); e.preventDefault(); custom_uploader = wp.media.frames.file_frame = wp.media({ title: 'Choose Collage Image',library: { type: 'image' },button: { text: 'Choose Collage Image' },multiple: false,displaySettings: true,displayUserSettings: false }); custom_uploader.on('select',function() { attachment = custom_uploader.state().get('selection').first().toJSON(); input.prev('input').val(attachment.url); }); custom_uploader.open(); }); 这很完美. if ( function_exists( 'add_image_size' ) ) { add_image_size( 'collage-large',460,660,true ); add_image_size( 'collage-small',325,true ); } 我的问题:
我在互联网上找到了一些地方.可能有用.
attachment = custom_uploader.state().get('selection').first().toJSON(); 通过附件,您可以使用: > alt >约会 >方向 > medium(< - 这是对象) >身高 >缩略图(< - 这是对象) >身高 > proto(< - 这是对象) >状态 为了解决您的问题,我建议使用上面的案例20: input.prev('input').val(attchment.sizes.collage-large.url); 希望这项工作! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |