For an Product entity I’m added custom field "images" // it contains all product images.

To display these images, CustomFieldFormatter is used, it is specified/set on the entity type "manage display" settings page. So each time the entity is rendered, it uses that CustomFieldFormatter, which display grid of images, with on hover and other effects.

But now I want to create a view to display grid of products (catalog page) and display only one (first) image of each product entity.

Please, help me find a way to change FieldFormatter for my field when it is shown inside "catalog" view. Or maybe there is some better architecture/solution?

  • Just add a setting to your formatter, implement that in viewElements() and then configure the display of your products to use that setting? for anything more, you'll need to share your code. – Berdir Mar 4 '16 at 16:18
  • I thought about that, but CustomFieldFormatter is used to display an array of Images field as galley [it has 1 main function, call it ZoomableGalleryFieldFormatter], so adding here setting to [stop acting as galley, act as single image] does not looks correctly – Vovka Mar 5 '16 at 6:59

The correct way to implement this, is to use "Display modes": add custom "Display mode" for entity, and set the another formatter for images field. In the View settings set it to use that "Display mode" to display entity.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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