Print EXIF data with WooCommerce Photography

Since the release of the latest WooThemes’ extension, WooCommerce Photography, a lot of photographers asked me how to print EXIF data on the photograph page.

This feature is not included in WooCommerce Photography. I did some research about what exactly EXIF data is (I’m not a photographer at all) and if is possible to get them with PHP and turns out that it’s possible, and easy.

With this tutorial you will learn how to add a custom tab in the single product page to show EXIF data.

Since I’m not a photographer I’m not really sure about what are the EXIF data that a photographer might want to show to his customer.

I inserted in the code, by default, those that seems to be the most important to me. Feel free to edit the code and add more data if needed.

But now let’s start.

Open your functions.php located in wp-content/themes/your-theme-name/ and add this code at the end of it:

This is all you need to print EXIF data.

In details, the first function, wc_photography_exif_tab, add a new tab in WooCommerce for all your photographs. If the product looped is not a photograph, the tab will not be added.

The second function instead, is the one that cares about getting and printing the EXIF data. Is the core of this tutorial.

As you can see from the code on line 32, there’s an array with the allowed extensions. This is because, EXIF data exist only in JPG, JPEG and TIFF photos. Since TIFF is not an allowed mime type in WordPress, i allowed only JPG and JPEG.

The code checks the featured image extension, with this array, and if allowed, will go ahead retrieving the EXIF data on line 37.

Also here, there’s an array with all the EXIF data we want to print in the single product page. As I said, I’m not a photographer, so I added in the list those who makes more sense to me. You can check the complete list of data available adding this code after line 37:

echo '<pre>'; var_dump( $exif ); echo '</pre>';

It will print a list of data in the tab on the single product page. Grab what you need and add them in the $allowed_exif array using the same format.

After that, the foreach loop just check if the looped EXIF data is allowed or not, and if yes, print it in the table.


This is how it should look in the single product page, using the theme TwentyTwelve:


I hope you find this tutorial useful for your business and your site. If you think that I missed something please feel free to comment!

P.S. Many thanks to Sven for sending me the photo I used to test, the one you can see in this screenshot above!

More Posts That You Might Like…

10 responses to “Print EXIF data with WooCommerce Photography”

  1. Hello

    Do not forget to sanitize output!!
    esc_html( $value )

    1. Hey Julio,
      thanks for your input! Is it possible to include HTML into EXIF data?

      I did not know, i’m fixing the code immediately!

      1. Why not? If you don’t know, sanitize 🙂

        1. Good point! 🙂 Fixed this morning! Thanks for reading!

  2. Hey Nicole,

    Nice to see working on improvements about Photography plugin. Hardly wait to see them more coming. 🙂

    I have tried to add your code to functions.php but after that I’m getting error below the EXIF tab:

    Strict Standards: Only variables should be passes by reference in …functions.php on line XXX

    and this XXX line in functions.php is:
    $ext = end( explode( ‘.’, $image_link ) );

    Can you please help me to figure out what is wrong and fix it? I would be really greatful for any help.


    1. Hey, thanks for reporting the issue!

      Change that line with this

              $image_link  = explode( '.', $image_link );
              $ext         = end( $image_link );

      I fixed it also in the article, just need to refresh the cache on my CDN.

      1. Hey, thanks for your super fast reply 🙂

        I have change that with highest expectations but no cigar 🙁

        Now am I getting two errors:

        Warning: exif_read_data() expects parameter 1 to be a valid path, array given in …functions.php line XXX

        XXX line:
        $exif = exif_read_data( $image_link );

        Warning: Invalid argument supplied for foreach() in …functions.php line XXX

        XXX line:
        foreach( $exif as $name => $value ) {

        Huh, a? 🙂

  3. Also find out that I have new error at WC Tabs;

    Fatal error: Call to a member function is_type() on a non-object in functions.php on line XXX

    XXX line: if ( $product->is_type( ‘photography’ ) ) {

    I’m afraid that I will wait for some bigger WC update because I’m not good with a code.

    Thanks anyway and have a nice day 🙂

    1. Sorry, it’s obvious that you get that error, my code change was bad 😀

      Use this instead of those 2 lines:

      $image_link_ext  = explode( '.', $image_link );
      $ext = end( $image_link_ext );

      Fixed also in the article.

  4. Great! Now it’s time for champagne and cigars 🙂

    Thank you for your effort!


Leave a Reply



Receive new articles from this blog directly in your inbox!

No spam guaranteed!

Blog at

%d bloggers like this: