count number of image attributes assigned

Permalink
Hello,

I have 5 page attributes setup using the image/file attribute. I want to run a check to see how many of the attributes have a file saved to it and obtain this value as a number. (e.g if three of the 5 have images the result would be 3).

Im not quite sure the best way to do this. I have put the attributes in an array and ws thinking of looping over each one and checking if an image is associated o each attribute, but the image/file page attribute is acting differently. I cant use it and receive an error..?

if (isset($page->getAttribute('classified_image1'))) { 
echo 'win<br>';
}