2

How to disable image caption in views block?

The image caption module is image field caption.

I apply it on my Drupal 7.

Enable module and add in caption. enter image description here

In node, it looks good. enter image description here

In View Block, it looks like this. How to remove the caption in Views block? enter image description here

==================================

Add View configuration image

Below is Views setting: enter image description here

Below is Configure field: Content: Image settings: enter image description here

2
  • How is that view configured? Is it a list of nodes rendered with a certain view mode (eg. 'teaser'), or is it a list of fields? Commented Dec 6, 2016 at 7:50
  • I have added in image. It is not list of fields. @marcvangend
    – JJ12345
    Commented Dec 6, 2016 at 8:07

2 Answers 2

2

If you're not picky, a possible alternative quick fix is to just hide it with CSS. This way you don't have to worry about or spend time patching the module.

You can do it like this:

.image-field-caption { display: none; } 

Note that the above will hide all captions, if you only want to hide the captions of a specific view:

.view-id-[name] .image-field-caption { display: none; }
2
  • Thanks. I have added . The caption is gone and looks fine. view .image-field-caption{ text-indent: -9999px; background:none; height:0; }
    – JJ12345
    Commented Dec 7, 2016 at 6:55
  • @JJ12345 note that the above will affect all views, if you just want to affect only certain views, then use .view-id-[name] .image-field-caption { display: none; }
    – No Sssweat
    Commented Dec 7, 2016 at 7:04
1

Given that you use the Image Field Caption module, this is not so easy. The module overrides the default image formatter (the chunk of code that controls how an image field is rendered) and adds its captions. There are two issues in its issue queue on drupal.org to make the module more flexible:

  1. Add ability to configure to display the caption based on view mode adds a configuration option to the image formatter, allowing you to choose to display the caption or not.
  2. Add formatters for image with caption instead of overriding the default proposes to introduce a separate image-with-caption formatter instead of overriding the default, so you can choose which formatter you want.

I have never tried these patches so I cannot recommend either of them, but you could try them (see the documentation on applying patches) and see if it solves your problem. Both methods should be compatible with Views. I would start with the first option because the code looks a bit simpler and it doesn't require database updates.

2
  • 1
    Worst case scenario, you can hide it with CSS.
    – No Sssweat
    Commented Dec 6, 2016 at 9:39
  • 1
    @NoSssweat Absolutely. Not the most elegant option, but it beats patching a module hands down in terms of speed and maintainability. In fact, that option should be a separate answer if you ask me. Commented Dec 6, 2016 at 12:23

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.