MakG10 / jquery-meme-generator

A jQuery plugin for interactive creating images with captions (memes) with basic image editing tools.
http://maciej.gierej.pl/en/jquery-meme-generator
59 stars 16 forks source link

[question] serialize or desserialize? #4

Closed diogobaeder closed 7 years ago

diogobaeder commented 7 years ago

Hi,

Pretty nice project! I'm searching for a tool to create memes and integrate it to a Django admin, however I need the capability to serialize and desserialize them in order to be able to store the meme state and let users change it whenever they want.

If this isn't supported yet, is it ever going to be supported in this library?

Thanks!

MakG10 commented 7 years ago

It's not supported, but you made a good point. I will add this feature in the next release. All you can do right now is to set text with captions options (text only, without any additional stuff like position, style etc.)

diogobaeder commented 7 years ago

Thanks mate! I'll wait for the next release, then. :-)

MakG10 commented 7 years ago

Hi, I added serialize and deserialize methods in the new version. Layers are serialized into the JSON array. Currently only text layers are supported, drawings aren't getting serialized.

When you call deserialize method you need to make sure to do that when the meme generator has been initialized (the source image has been loaded and UI controls have been created). You can use onInit event for that if you want to deserialize data right away:

$("img").memeGenerator({
    onInit: function(){
        this.deserialize('json to deserialize...');
    }
});
diogobaeder commented 7 years ago

That's awesome, man, thanks a lot! :-)