Hi team,

Using the Media module https://www.drupal.org/project/media (which allows to select images from the server), can we search an already-uploaded image based on some taxonomy terms associated with it? I can see it allows searching based on file names only. Can someone please help asap?

Thanks.

Comments

pixelsweatshop’s picture

Just like content types, you need to go and add your tag field.

Go to your file types and add a taxonomy or entity reference field. /admin/structure/file-types

Then go to the media browser view and add the exposed filter of your newly created tags field /admin/structure/views/view/media_default/edit

ljacob’s picture

Thanks a lot for the prompt reply.

Now an additional question: If a content type has a tag field, can we automatically assign that tag to an image field in that content type (while saving the content)?

pixelsweatshop’s picture

You could do this using rules, but without knowing intimately what your current setup is, I can only point you in the general direction. Using the rules module: https://www.drupal.org/project/rules

Event: upon saving a node of type x
Condition: if your image field exists and isn't empty, also has tag field (you may also have to pull the media entity into scope)
Action: Set data value of the media entity tag field with the value of your node tag field value.

Otherwise you would have to code something yourself or have the user add the tags to both manually.