javascript - 使用 wp.media 裁剪图像的 WordPress 插件

标签 javascript php wordpress image plugins

我在我的新Wordpress插件开发中使用这个功能,这工作正常,使用Wordpress Media Uploader进行图像上传,但是我需要使用预定义的裁剪功能在上传后裁剪图像,我不知道该怎么做.

function wilson_newsletter_media_library(big_parent){
    var frame_uploader, datos_imagen;
    if ( undefined !== frame_uploader ) {
        frame_uploader.open();
        return;
    }

    frame_uploader = wp.media.frames.frame_uploader = wp.media({
        title: "Insert Media",
        button: {
            text: "Aceptar"
        },
        multiple: false
    });

    frame_uploader.on( 'select', function() {
        datos_imagen = frame_uploader.state().get( 'selection' ).first().toJSON();
        big_parent.children('img').attr("src", datos_imagen.url);
    });

    frame_uploader.open();
}

我真的很感谢任何帮助。

最佳答案

我在 WordPress Stack Exchange 网站上发布了一个可能的解决方案,该解决方案展示了如何使用主题选项页面中的媒体库选择和裁剪图像: https://wordpress.stackexchange.com/questions/281760/using-media-uploader-to-select-image-of-specific-size-enforce-cropper/302962#302962

关于javascript - 使用 wp.media 裁剪图像的 WordPress 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48082713/

相关文章:

javascript - 在 React JS 中序列化 <form> 数据提交 POST 请求

php - 如何使用 PHP 从数据库中检索某些表?

php - 关闭 mysqli 连接会产生 : Couldn't fetch mysqli_result

wordpress - WP 高级自定义字段 - True/False 字段 if/else 语句

mysql - 在 mysql 命令中查找重复行

javascript - 映射减少 : How to count in a collection

javascript - 对 Angular Provider 的依赖注入(inject)

javascript - 原子 : Where is the list with all the default snippets?

php - 错误异常 : Undefined variable laravel

php - Wordpress:事件主题未显示在 'Themes' 文件夹中