Something wrong in my project, using fabric.js

function loadimg(src){
        var newww=new fabric.Image.fromURL(src,function(img){
            H_PADDING: 20,
            V_PADDING: 50,

    // window.canvas_obj.add(neww);

that is my package function to load an image to the canvas and I want to select the image object that was put into canvas by the API canvas.setActiveObject(canvas.item(i)) but it only finds the item(0), 1, 2, 3. Once more, it can't find it.


what you need is to load an image and make it active ?

If so, i created a jsfiddle example that loads an image and activates it.

var canvas = new fabric.Canvas('c');
canvas.backgroundColor = 'yellow';

var site_url =  '';

//i use loadSVGFromURL to load an svg image but it is the same if you would like to use fabric.Image.fromURL() to load your image
fabric.loadSVGFromURL(site_url, function(obj) { 
          var img = new fabric.PathGroup(obj, { 
          left: 165, 
          top: 100, 
          width: 295, 
          height: 211 
//add the loaded image on the canvas
//activate(select) the image
//render canvas to show the borders on the image

jsfiddle :

hope helps ,good luck.

Need Your Help

jqPlot bar graph with multiseries showing empty data series

javascript jqplot

I´m building a dynamic 6 series bar graph with jqPlot. In my implementation, the user will choose which data will go into each serie and the system will load data according to his choice. The funct...