LocalFiles image path contains 'public'
See original GitHub issueHi,
First of all I’d just like to say thanks for an amazing cms : )
After implementing the localFiles field type within my model the images do not correctly show within the admin ui.
The path to the images contains ‘public’ which obviously can’t be accessed frontend.
I’ve worked about this by adding this line above live 15 in keystone/templates/localfiles/form.jade
- value.path = value.path.replace('public/', '')
Is there a nicer way to solve this?
Thanks,
Issue Analytics
- State:
- Created 9 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Why can't I do <img src="C:/localfile.jpg">? - Stack Overflow
If we want to display images from local drive into our img tag of HTML page directly then we need to give relative...
Read more >UOMF: Path-Independent Links to Local Files Via Locate
For linking to local files, I have already written about my tsfile: custom link method using Memacs. I use this for managing local...
Read more >media - How to change the default images path and direct it to ...
After saving it, select Private local files served by Drupal as Default download method . ... in the public or private image directory....
Read more >File target: add support for local file path as source - Drupal
I have a use case to import content with file url. ... I have the need to import local files too (around 50000...
Read more >How to enable ability to input local image files in to node red ...
Then you need to change the value of httpStatic to be the full path to the folder containing your images. After you restart...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry to take so long to get to this! it was a real headache, there were a lot of things to fix in the
LocalFiles
field type when I started digging into it, so that this wasn’t just a hacky fix.I’ve brought the field implementation into line with the
LocalFile
type, and it now supports the same options ofdest
,prefix
andformat
. This allows you to upload files to locations other than thepublic
folder (which I personally would recommend) and still have them work correctly with public paths.In my test project I have it working, including image previews, and it looks like this:
In
keystone.js
Set add whatever path you’re uploading files to as one of your static paths, using an array:
In your Model
Specify the
dest
as the folder you want the uploads to go into, the same one you exposed with yourstatic
option. Set theprefix
option to the public path of that directory, and if you’re using images, you can also set aformat
option to display thumbnails.As you can see in the example, there’s also a new
href
property on the file inside theformat
funcition that gives access to the public href, it’s available on the List too.For more details, check out the commit I did all this in.
If anything else isn’t working, please let me know, and I’ll sort it out.
Thanks for pointing that out @tylkomat, I’ve fixed it and will push a new version soon.