Drupal 8: How to get the ['third_party_settings'] of an image field inside hook_preprocess_image_formatter(&$variables) I have a custom module that requires that I pass variables to my image-formatter template via hook_preprocess_hook(), in this case hook_preprocess_image_formatter(). 

From within the preprocessor, I would like to acquire $field_display['third_party_settings']['My_Module'] 

I should be able to do that by exposing the #view_mode and the #field_name of the ImageObject I am preprocessing. I may even be able to hard-code #view_mode = 'full' in which case all I need to do is exposed the #field_name in my processor to acquire the ['third_party_settings']. Any ideas?

EDIT: I forgot to mention that I will be heavily depending on the data that is contained in the image object that is contained within $variables['item'] to acquire the info needed for this. A gist of part of that object can be found at the following url with data containing the field_name: https://gist.github.com/awasson/55ad5da56076e5cb57dd8f3aa68a05f0

Thanks!
Although this is pretty specific, it may help someone else with a similar problem.

The answer is in getFieldDefinition() object of $variables['item']. 

In order to acquire the field name of an image object from within HOOK_preprocess_image_formatter(&amp;$variables) which is a variation of HOOK_preprocess_HOOK(), you would use: 

$field_name = $variables['item']-&gt;getFieldDefinition()-&gt;getName();

Used within the context of a module file it would look something like the following:

/**
 * Implements hook_preprocess_HOOK()
 * This allows us to pass attributes to the image_formatter template.
 */
 function MY_MODULE_preprocess_image_formatter(&amp;$variables) {
   // Get the field name
   $field_name = $variables['item']-&gt;getFieldDefinition()-&gt;getName();
 }