How to change the image field to include a caption and how to add more color options in the color field


I want to add a caption to an un-CDS image in image gallery, how can I add something like that’s?
How can I add other BG colors or font colors to article box, thumbnail box…?



Hello Abdul,

I am answering your questions one by one:

I want to add a caption to an un-CDS image in image gallery, how can I add something like that’s?

  • Images are fields inside paragraph types. As you have already noticed, by default they don’t render with a caption. So obviously you will need a separate text field which will play the role of the caption.
  • After adding the additional field, you need to change the way the image field is rendered. This can be achieved by creating changing the template of the field for this specific paragraph type. To save some time I suggest you a nice medium article on how to modify the template of a field in a content type. The only difference between your implementation and the article is that the article modifies a field of a content type while you should modify the field of a paragraph type [The technical difference is that instead of field–node–field…html.twig, you should have field–paragraph–field…html.twig]. You can find more about drupal template conventions on this Drupal documentation..

How can I add other BG colors or font colors to article box, thumbnail box…?

Good question. Color fields of Article Box, thumbnail box etc are also fields in paragraph types. If you visit the “Manage Form Display” page of Article Box - for example /admin/structure/paragraphs_type/cern_article_box/form-display - then you will notice that there is a list of HEX color codes33

You can append this list with the desired colors.

Hope this helps. Let me know if you have more questions.

Best Regards,


Hello Kostas,

I would like to look at the template for the image field in the CERN Image gallery paragraph (to have an exemple) but I can’t find the file.
Thank you,

Hello Jan,

The pattern that generates the image gallery is called gallery and you can find it here.

Let me know if you need something else.


Hello Konstantinos,
Thank you for the link.

If I understand well, in the Image gallery paragraph type, the title field in the Image gallery Image field settings is not used. I tried to enable it but its content is not rendered in any way.

But in the case of the image field default display outside a paragraph, this title field is used as title attribute, which is very convenient. It could also be used as caption when the pictures are opened in colorbox. At the moment, “no caption” is displayed for non-cds images in both cases. But cds images get their caption displayed. Can’t the same be done for non-cds images?
Otherwise I think in this case I just can’t use an Image gallery for what I need to do. I could use a slider or a view but I would prefer the gallery.
Thank you,

Hello Jan and thanks for the feedback. As you already mentioned the captions are supported only for CDS images for now. That happens because CDS images are based on a custom field that automatically retrieves captions from the CDS API.

On the other hand, local images use the default image field of Drupal which does not support captions by default so we would have to implement it in a custom implementation. In general the process should include adding a separate field for the caption and also overriding the default image template to include the caption or create a custom field formatter.

It is on the plans to integrate it but to be honest I hope to have a module that implements it since it is a quite basic functionality.

My problem is that it does not work in bilingual website.
Do you know how to have additional colors in the second language please?