question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

File upload thumbnails not displaying in AdminUI

See original GitHub issue

Bug report

Describe the bug

When uploading a file with the File field (I’m using the LocalFileAdapter), the thumbnail will show up in the Create dialog, but not when viewing the entry in the list (see below). I have both src and path properties of the file adapter set to the same place:

const fileAdapter = new LocalFileAdapter({
  src: './files',
  path: './files',
});

keystone.createList('FileTest', {
  fields: {
    name: { type: Text },
    file: { type: File, adapter: fileAdapter },
  }
});

A look in Chrome seems to indicate it’s trying to fetch the files from localhost:3000/admin/files instead of localhost:3000/files (where they actually are). Not sure how to fix this one.

Screenshots

image

image

System information

  • OS: Windows 10 1903
  • Browser: Chrome 78

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
HostenMarijncommented, Dec 1, 2020

Hey guys,

I’ve been setting up a Keystone + React project and bumped into the same issue. Found a solution that works with my setup.

Make sure that the StaticApp src starts the same as the FileAdapter src (in my case …/my-app)

Folders:

  • my-app

    • public/files/1234image.png
    • build
    • … other CreateReactApp things
  • server

    • lists/product.js
    • index.js
    • … other KeyStone things

index.js

new StaticApp({
      path: '/',
      src: '../my-app/build',
      fallback: '../my-app/build/index.html'
    })

product.js

const fileAdapter = new LocalFileAdapter({
  src: '../my-app/build/files',
  path: '/files'
});

And then finally the resulting frontend code

{products?.map((product, idx) => <div key={idx} className='product-card'>
          <img src={`http://localhost:3000/files/${product.image?.filename}`} alt={product.name}/>
          <div className='bold'>{product.name}</div>
          <div>€{product.price}</div>
          <div>{product.description}</div>
        </div>

PS: make sure to build your client first, otherwise your uploaded images will be overwritten by the new react app production code

Hope this helps anybody!

1reaction
gautamsicommented, Oct 24, 2019

You also need the @keystonejs/app-static or express.static path configured

Read more comments on GitHub >

github_iconTop Results From Across the Web

opencast - .. - admin-ui - thumbnails.md - ZIVGitLab
An Uploaded Thumbnail is uploaded by the user. As both the video editor and your workflows need to work together to enable full...
Read more >
WP Native Thumbnail not showing with the Image Shortcode ...
The issue is that if I upload hundreds of images at once, I have to manually go in and edit each one by...
Read more >
How to display KeystoneJS thumbnail/preview images stored ...
File and Types.Url to return the image tag as a thumbnail/preview, but no luck with both of them, I noticed that format was...
Read more >
Display an image in the admin grid in magento 2
I'm using the new grid system, the one with ui components. I took a look at how the thumbnail is added in the...
Read more >
[Solved ]Problems with Video preview in admin UI - Installation
When I upload a mp4 file and try to preview it in the admin UI it does not load. Do I need a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found