fengyuanchen / cropper

⚠️ [Deprecated] No longer maintained, please use https://github.com/fengyuanchen/jquery-cropper
MIT License
7.75k stars 1.74k forks source link

Jquery Change Image by URL #1043

Closed mirkomassarutto closed 4 years ago

mirkomassarutto commented 5 years ago

I want to select the image to crop clicking on a list of images on my server

I tried this:

$(document).on('click', '.editthisphoto', function(){
    //getting the new image name (i.e. "/images/1.gpg"
    var mynewimage = $(this).parent().children().attr("src");
    //replace the image name in the "image" id on the page
    $("#image").attr("src",mynewimage );
    //Now, if i inspect the code the image is changed, but how can i "reinitialize" the cropper?
    // I Tired:
    $().cropper('destroy');
    // And tryed also:
    $().cropper('destroy').cropper('replace', mynewimage )
    return false; 
}

Can anybody tell me what to do? thanks

fengyuanchen commented 4 years ago

It seems no one can help you.