I want to list All the images that are present in more than one article.
My setup is like this. I have a content type "article" and it has a field of type "Field Collection" (field_medias), the field_medias has the following fields: field_media (without "s") and field_caption.
I can select all the images with the following EntityFieldQuery
$result = $query->entityCondition('entity_type', 'field_collection_item') ->entityCondition('bundle', 'field_medias') ->fieldCondition('field_media') ->execute();
And I can select all the articles with the following query:
$result1 = $query1->entityCondition('entity_type', 'node') ->entityCondition('bundle', 'article') ->fieldCondition('field_medias') //has a image ->propertyOrderBy('created', 'DESC') ->execute();
How can I select all the images that belong to at least 2 articles. Is that possible using a single EntityFieldQuery?
As I have hundreds of thousands of articles and hundreds of thousands of images I have to avoid resource hungry queries.