Data manipulation is one of the most basic fundamentals in creating functions and procedures and in Drupal, it's doing all the work for us and making it easier to access those information and what's more about that we can create our own function and create our own variable and be called together with the default variables, and with this in Drupal its achievable thru hooks.

Hooks allow modules to alter and extend the behavior of Drupal core, or another module. They are one of the various ways that code components in Drupal can communicate with one another. Using hooks a module developer can change how core or another module works -- without changing the existing code.From an implementation perspective hooks are specially-named functions called at specific times to alter or add to the base behavior. There are many type of hooks but for this topic we will work on the hook_preprocess. This hook allows modules to preprocess theme variables for theme templates. It is called for all theme hooks implemented as templates, but not for theme hooks implemented as functions. hook_preprocess_HOOK() can be used to preprocess variables for a specific theme hook, whether implemented as a template or function.

Example:

Changing field template suggestions

From the get go, Drupal gives us lots of options for templates that each field can use. Sometimes, though, you may want to point multiple different (programmatically unrelated) fields to the same Twig template. A common use case that I personally employ on most projects is something like field__bare - a field template I create that has no wrapper divs, labels, or classes, but simply renders the field's contents. There are plenty of other design reasons that you might want different fields to point to the same template, though.

/sites/default/files/assets/images/article-image/Anosa/Screen%20Shot%202020-12-21%20at%2013.19.39.png