In Drupal 9, We have a image field in the content types where we have a option to provide values for alt and title attributes. These values will be used for SEO improvements.
Is there any way or modules available to auto pull content title value for image alt and title attributes? Something like token replacements.
Thanks in advance.
2
Answers
imagefield_tokens module helps to accommodate this requirement.
Note: In Image - Manage Field - Configure default value as [node:title] to get Content title value in image alt and title attributes.
Yes, you can use the token module to see the site tokens in a user interface by going to: admin/help/token
So the token value for the alt field would be something like:
[node:field_image:alt]
And for the title:
[node:field_image:title]
You can also use them in a custom theme template by using:
I find using the Metatag module helpful to achieve what you want to do here.