0

I wanna add in a block configuration form an image field that can take several images, just like in a node form, with all the drag'n drop stuff, etc. Any advices or solutions?

1 Answer 1

0

The solution is an image field configured in a custom block type.

Block forms are configuration and don't support image fields. Custom block types are content and they support the same field types as nodes.

If you can't do what you want with a custom block type, you can create your own block plugin which uses a block content entity.

For background information see these questions Adding custom block problems and Blocks: Old vs. "Custom" and Config vs. Fields.

4
  • In fact, I use the hook_block_configure to add an image_field in my form, but I can only upload one image by field. Commented Apr 11, 2017 at 12:34
  • Then this is for D7, the problem is basically the same, but the solution is different, see drupal.stackexchange.com/questions/103180/…
    – 4uk4
    Commented Apr 11, 2017 at 12:42
  • Yep, I already use $form[xxx] with the managed file parameters but for exemple i got a slider with 5 images, i have to add 5 image field in my form. What i want to do is to have only one field for my five images. (I'm sorry if I made mistakes or don't understand, I'm french and my english is not perfect. :) ) Commented Apr 11, 2017 at 13:03
  • The issues with image fields in configuration are perfectly described in the linked questions. It might be easier to take a different route and use a node type or entity type with an image field.
    – 4uk4
    Commented Apr 11, 2017 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.