Is it possible to prepopulate a file field?

Comments

eminencehealthcare’s picture

Use FileField source remote url and use the prepopulate module to fill it with the URL to the file.

juliencarnot’s picture

Issue summary: View changes

I'm using Drupal 8.1.1 and I was wondering if I could use Prepopulate to inject the local URL of a picture in the Image input of a form.

I tried to do this with the URL https://mysite.not/node/add/article?edit[edit-field-images-0-upload]=/ho... but wasn't successful. "edit-field-images-0-upload" is the id of the input field in the form, and /home/user/test-image.jpg is the local path (on my computer) to the image I'd like to prepopulate to my form. I tried including quotations marks around my local path too, with the same result.

Is there a way around this? I don't get what the "FileField source remote url" mentionned above would be. Any example would be greatly appreciated!

SeanA’s picture

I believe the suggestion is to use https://www.drupal.org/project/filefield_sources and configure the field to use a "Remote URL textfield".

juliencarnot’s picture

Thanks a lot for the hint SeanA, that makes sense! Couldn't test it on Drupal 8 though, the filefield_sources dev branch is not working for me at the moment, but I'll check that out!

SeanA’s picture

Sure, and I can confirm that it works on D7 at least.

Dandily’s picture

Thank you SeanA! It's work fine for me for remote image:

&edit[field_img][und][0][filefield_remote][url]=

But i don't know, how could i add any count of images with infinite field...
It's work only for generated fields, new one will not filled.

Does anybody know how to add any quantity of images?