How to add custom content in fabric.Image()

前端 未结 1 1753
[愿得一人]
[愿得一人] 2021-01-22 17:42

I am trying to use the following suggested way to store canvas in the server:

Fabric.js - how to save canvas on server with custom attributes

But in my case, I a

相关标签:
1条回答
  • 2021-01-22 18:21

    Here my solution to store custom attribute (id).

    fabric.Image.fromURL(link, function(img) {
        img.set({
            id : 'image_'+index,
            width : canvas.width / 2,
            height : canvas.height / 2
        });
        canvas.add(img).renderAll().setActiveObject(img);
    });
    

    For quick review here is a working code : http://jsfiddle.net/mullainathan/dpyb7cf7/1

    0 讨论(0)
提交回复
热议问题