The field preprocess hook only works when you render the field. Once you start extracting values off the field object (like individual properties or specific deltas), you're no longer rendering the field itself thus not triggering the hook.
I also do not recommend extracting and rendering data this way because you're losing some metadata that come with these objects (e.g. cacheability, theme info, formatter info, modifications from other modules, etc.). You could:
- Create a Field Formatter for that field type and only render a specific delta (by overriding
viewElements()
and only adding specific deltas). You can make the delta configurable.
- Or a combination of
hook_field_formatter_third_party_settings_form
and hook_preprocess_field
. The former will let you save configuration into field display config, while the latter allows you to pick up that config and modify the field output.
- A good example of this combination (albeit used for a different purpose) can be found in the Fences module.
In both cases, you can choose to make them configurable via admin and not hardcoding the delta selection into template. You can even make it so that you can ignore both entirely, leaving the field rendering the default output.