1

How to use image field in a condition of an entity query?

To get X nodes which have no image as value of field_image I've tried this:

$nids = \Drupal::entityQuery('node')
->condition('type','X')
->condition('field_image',NULL , '=')
->execute();

it doesn't work I got always empty result.

3

You could try: $query->notExists('field_image');

  • It works just perfect, Thanks dude ! – MiharbKH Nov 28 '18 at 13:47

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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