Is it possible to target a fieldtype by it's Type name, rather than the handle name? I've created an Asset Source and assigned my own field via the field layout. 

Then, I created an Assets Field to display a single image on a page. Using my plugins twig extension I can query the image object like so:

{{ entry.featuredImage.first()|myTwigExt }}


Now, in the Twig extension I want to target the first instance of my field using its Type, not the Handle.



The reason for this is because the handle can be defined by the user, but the type name is always the same. I want to avoid the need to parse in the field handle along with the Twig Extension like this:

{{ entry.featuredImage.first()|myTwigExt('notThis') }}


If this is even possible, my ideal situation would have my Twig Extension looking something like this: 

  public function getFilters() {
    return array(
      'myTwigExt' =&gt; new Twig_Filter_Method($this, 'myTwigExtension'),
    );
  }

  public function myTwigExtension($image, $param) {
   if ( $image-&gt;type('myCustomField') ) {
     // YAY!
     return $image-&gt;type('myCustomField')-&gt;someDataFromMyField;
   }

   if ( $image-&gt;$param ) {
     // "Boo!";
     return $image-&gt;$param-&gt;someDataFromMyField;
   }
  }


This is the cleanest way I can ask this question. Without going into too much detail about my plugin (which would just confuse the situation more).
I am not sure if I am understanding your question correctly, so here is my understanding before I give my solution:

You want to be able to access a field on an asset by it's field type rather than it's handle.

Given this understanding, here is my solution:

I have not been able to accomplish this using Craft relations. However, you can loop through the fields attached to the asset, and check their type. It is a little bit confusing as Craft stores the data for fields and field layouts across several tables. 

An element has a field layout (FieldLayoutModel), and the layout then has fields (FieldLayoutFieldModels). Then each of those FieldLayoutFieldModels has fields (FieldModel) which are the actual fields we are looking for. Putting this together, we can loop through and check the field type like so:

    // get the fieldLayoutModel
    $fieldLayoutModel = $image-&gt;fieldLayout;

    // get array of FieldLayoutFieldModel
    $fieldLayoutFields = $fieldLayoutModel-&gt;fields;

    foreach($fieldLayoutFields as $fieldLayoutField){

        // get the field associated with the layout
        $field = $fieldLayoutField-&gt;field;
        if($field-&gt;type == 'myFieldType'){
            // do whatever
            break;
        }
    }


Hopefully this is what you were looking for!