Search code examples
javascriptjqueryfabricjs

getting image src in fabricjs


hi i am using fabric js for image resize and and drag and drop. now i want active object src . so i try like this way

 canvas.on('object:selected', function () {

        currentObject = canvas.getActiveObject();
        var imagesrc =currentObject._originalElement.currentSrc;

but the result getting like

http://localhost:2200/Images/design/fullbar_1.svg

i need only the fullbar_1.svg from this .how i seperate it from this


Solution

  • First save your path in one variable and then split & get your file name

    var url="http://localhost:2200/Images/design/fullbar_1.svg";
    
    var check = url.split("/");
    alert(check[check.length-1]);