The site I am working on uses many content types and almost all of them use one or more image fields. Image fields are not shared between content types, so there is a big number of them.
What I need is to get the first image field from a node, assuming there are more image fields linked to a node and without knowing the name of any of these fields. The first one is considered to be the one with a lower weight
.
This should build you an array of the "lightest" imagefield per content type.
Then when you load a node of, say, the "product" content type, you know which imagefield is the lightest (i.e
$node->$lightest_imagefields[$node->type]
).Hope it helps. (test it before using it, though!)