I have a feature on a site I'm working on where it would be easiest to add an extra field attribute (along with alt and title) to the image field. Ideally a select list with a few different options (think categories for the uploaded image). Doing this goes beyond the scope of what I'm *used* to doing within Drupal.

Can you point me in the right direction on where to look in order to accomplish this, or if you're familiar with a pre-existing module that might already accomplish this, that would be awesome as well!

Thanks in advance

Comments

RoloDMonkey’s picture

What do you want to do with the attribute after you collect it? Will it be used as a filter in a view? Will it be added to the HTML as a class?

--

Read more at iRolo.net

ezoolander’s picture

as a filter in a view. Basically it's to assign the uploaded images to a group.

ezoolander’s picture

although if it turns out to be a LOT more complex to add it as something filterable in views - so long as it would be part of the field attributes passed to twig I can do a JS workaround after page load. So whichever has the quicker learning curve to get the project complete. :)

RoloDMonkey’s picture

You could define the image field and the new field as a field collection:

https://www.drupal.org/project/field_collection

That should work with views.

--

Read more at iRolo.net

ezoolander’s picture

Gracias - I'd forgotten all about the field collection module. Thanks for reminding me!