Own Image gallery in KeystoneJS

842 views
Skip to first unread message

Luca Antonazzo

unread,
Feb 12, 2016, 3:42:35 PM2/12/16
to Keystone JS
Hello,

I'm new to KeystoneJS and I like it a lot, as it fits my needs perfectly... except for the Cloudinary gallery. I would prefer a storage solution on my own server.

How do I swap out the Cloudinary part and replace it with a gallery with the same functionality, but instead saved locally?

Sorry if this question seems obvious, but this is my first node.js project.


Thanks a lot for any help

Maxim Likissa

unread,
Feb 12, 2016, 8:26:57 PM2/12/16
to Keystone JS
I had a little trouble but this is what I did myself (community peeps please correct me if I'm wrong!)

Define the image in your model as:

image: {
type: Types.LocalFile, 
dest: 'path/to/files', prefix: '/to/files',
filename: function(item, file){
return item.id + '.' + file.extension
}
            }

in the keystone.js file, make sure that the folder where images will be uploaded is set:

keystone.set('static', ['path','to', 'files']);

I think there is a type: Types.LocalFiles, option as well for multiple files... quick googling:

This is what I found most helpful on this:

Chris Troutner

unread,
Feb 13, 2016, 6:04:11 PM2/13/16
to Keystone JS
I wrote a tutorial on my blog about how I got my own image hosting working in KeystoneJS:


Luca Antonazzo

unread,
Feb 14, 2016, 12:54:33 PM2/14/16
to Keystone JS
Thanks for your answers!

I tried implementing it with LocalFiles, but I've got some issues with filenames / uploading (pictures uploaded multitple times, cannot remove double entires). I'm not sure if it has to do with the file namig or database. But at least there are locally hosted images now.

I also tried to follow the tutorial, but as for now it's a bit too advanced for my node.js knowledge. I will take a look at it at a later stage (as I will need something like this sooner or later). But for now, I'm trying to get the most basic things working.


Is there also a way of making own file types? For example something like "LocalImage"? My goal is something like the demo app (http://demo.keystonejs.com/gallery), but with slideshow gallery.

I'll get there eventually....

Cheers
Reply all
Reply to author
Forward
0 new messages