image: { type: Types.LocalFile,dest: '/home/veda/ks/public/img', prefix: '/img',
format: function(item, file){
return '<img src="/img/'+file.path.replace('/home/ks/admin/public/img','')+'/'+file.filename+'" style="max-width: 200px"\>';
}
},

It show an image on keystone version 0.2.36 but when I update to keystone 0.2.40 it show file name instead.
I can confirm this is (for now) not working in the new React fields, we may need a new strategy to support it. AFAIK the feature was used entirely to support image previews, so maybe we should just make that an option.
Would be nice if you could put a notification on the keystone documentation. Thanks
@dtuyenle a notification of what?
I'm bumping this to an 0.3.x release, and will include a note that if you're dependent on this you should wait a little bit before upgrading from 0.2.x
Just ran into this. +1. Agree, file preview option would suffice, though at the same time, I think a longer-term feature might be able to enable a custom format() function on every field.
Would be great to have an option for localfile and localfiles fields to set if it's image and render preview if it is, maybe even add option for videos, sounds in the long run but images would be highest priority I believe.
and regarding format as @adamscybot mentions having option to format every field would be great way to do simple adjustments without having to hack or create custom fields for keystone for many less complex use cases. For example being able to display image preview in place of name in the relationship field could be great usability helper that could be easily handled with that.
See #1222
I would love to add functionality like this to the common File field - let's get that merged and go from there.
:+1: I like the idea.
If change to common file field will that change data schema on mongodb? I'm working on project that depend on Localfile field.
Same with S3File #2215
How it works now????
I have "keystone": "0.3.17", and format still not called, and there is no preview for localfile.
So, the documentation confuses...
I just wanted to bump this for attention, it's also a problem with s3 files. Anywhere where to look for a fix? I'd be willing to submit a PR if anyone knows where the potential problem lies.
it's probably the browser rendering the location string, instead of loading the image from the internet. Hard to say without looking at a sample in the browser myself.
just want to bring this PR to attention. #2484 i merged it into my fork and everything works as expected.
Just ran into this. I think the documentation should be updated to reflect that the format function does nothing.
@JedWatson:
AFAIK the feature was used entirely to support image previews
I need to specify a format function for an S3File because I want to be able to generate a signedUrl with knox, so users can easily download a private file.
I'm really not familiar with Keystone's codebase or React, but I've been poking around … would it be possible to call the custom format function on the server, include the value in the item API call, and include it with <div dangerouslySetInnerHTML={{__html: this.state.customFormatHTML}} />??
I just hit this as well. The documentation is for a feature that simply doesn't exist or doesn't work as documented.
The docs should just be updated to removed this format feature all together as it appears to be unsupported. Specifically this is for the S3File Type
Sorry for the frustration here. I'll get the docs updated asap, and take the option out.
The file fields were inconsistent and too much of a maintenance burden in 0.3. We've completely rewritten them with pluggable storage in 0.4 which is in final testing now, unfortunately we won't be back porting this in the interest of getting the new version out.
The sooner we can hit that release, the sooner everybody will be unblocked. If anyone is interested in helping finish either the S3 or Azure adapters for the new File field, please ping me!
@JedWatson is there any work around for this? Anything i can edit in Keystone js internals to make this work?
Can you please keep the docs updated? It is really frustrating. I am having trouble working with local files in my project.
As noted in earlier comments, the File API has been rewritten using pluggable storage for Keystone 4 (née 0.4).
For more information, see the File Field API documentation and API File and image Uploads Guide in the Keystone 4 documentation.
For specific File adapters, see:
Regards,
Stennie
Most helpful comment
just want to bring this PR to attention. #2484 i merged it into my fork and everything works as expected.