Where can I store a global Image javascript object?

Hello,

I am using html5 canvas on one Blaze template.
I need to create an Image object to load an image, the image is random and the filename comes from the database.

Where can I store the Image object? or should I add a hidden img tag in my template.
I need to access the object in different places: events, helpers, hooks (onCreated, onRender).

Thanks.

I can not save the imageObj = new Image() in a ReactiveDict.
I tried and it does not work, why ?

I’m not an expert on images, nor on what you’re trying to accomplish, but I made an app a couple of years ago that allowed the user to take a photo and add i to a list of other alerts (kind of like chat with pictures). I stored the images as base-64 text in the collection, then retrieved them as needed. Worked fine for a small application with limited users, but you’d most likely want a better storage engine if you were to have a lot of usage.

1 Like

Thanks, saving base-64 encoding is a good option.

1 Like