For a while I was wondering why the EXIF section of my theme shows only the camera model and not the manufacturer. For example, a “Nikon E5200″ shows up only as “E5200″. Then I found out that WordPress itself somehow imports only the model number into the database and not the maker. Considering my modest programming knowledge I knew this wasn’t going to be easy.

But I really wanted that manufacturer to show up.

So, I embarked on a night-long journey searching for codes that look relevant, and found one in /wp-admin/includes/image.php which is this bit from wp_read_image_metadata around line 277:

$exif = @exif_read_data( $file );
if (!empty($exif['FNumber']))
   $meta['aperture'] = round( wp_exif_frac2dec( $exif['FNumber'] ), 2 );
if (!empty($exif['Model']))
   $meta['camera'] = trim( $exif['Model'] );

As you can see, there is no camera maker. First of all I’d need to find out what it’s called internally. A little visit here shows that it’s called “Make”.

One way to do this would be to make wordpress import camera maker into the database by adding another variable to the array (line 241) like this:

$meta = array(
 'aperture' => 0,
 'credit' => '',
 'camera' => '',
 'maker' => '',
 'caption' => '',
 'created_timestamp' => 0,
 'copyright' => '',
 'focal_length' => 0,
 'iso' => 0,
 'shutter_speed' => 0,
 'title' => '',
 );

and then add two lines after wordpress imports Model:

if (!empty($exif['Model']))
   $meta['camera'] = trim( $exif['Model'] );
if (!empty($exif['Make']))
   $meta['maker'] = trim( $exif['Make'] );

Then you can access the camera maker by something like:

$imgmeta = wp_get_attachment_metadata($attachment_id);
$imgmeta['image_meta']['maker']

There are two problems with this. First of all, you need to reimport all your existing photos otherwise the database won’t be updated. And second, more importantly, it’s a generally bad idea to modify wordpress core files, and they’re wiped out when you upgrade. I don’t want to have to do this every time I upgrade too, so I thought of another way.

The Other Way …

The solution to the first problem is to simply go read EXIF data from the image file, so you don’t need it from the database. This will work on your existing images in existing posts. And the solution to the second problem is to place codes in theme files (probably functions.php).

However, since what you need to modify is dependent on what’s in your themes, I can only show an example. In my case, I was working with AutoFocus theme by Allan Cole. So I searched in the theme’s functions.php for the code that shows EXIF data, which is grab_exif_data() (line 604).

I added this to the beginning of the function to read EXIF data directly from the image:

global $post;
$exif = @exif_read_data( get_attached_file($post->ID) );

And then added trim( $exif['Make'] ) in front of the camera model to show the manufacturer:

echo "<li<span class=\"exif-title\">Camera:</span> " . trim( $exif['Make'] ) . " " . $imgmeta['image_meta']['camera']."</li>";

The result is something like this:

Camera: NIKON E5200

Hopefully you can adapt that into your theme. You can check out the finished product on my photoblog.