• Im using this function in my new WordPress plugin development, this works ok, using WordPress Media Uploader for image upload, but I need to use a predefined crop functionality to crop the image after upload and I don’t know how do it.

    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();
    }

    Can I use “WP_Customize_Cropped_Image_Control” in some way to crop the image?
    I really apreciate any help.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Customizer controls are only useful within the customizer. At root you need to use WP_Image_Editor_GD or WP_Image_Editor_Imagick class, depending on which image processor is installed on the server. Use wp_get_image_editor() to load the correct one. If you want the normal WP image editor UI, call wp_image_editor().

Viewing 1 replies (of 1 total)
  • The topic ‘WordPress plugin using wp.media to crop images’ is closed to new replies.