Print EXIF data with WooCommerce Photography

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

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 built 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 also easy.

With this tutorial you will learn how to add a custom tab in the single product page in order 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:

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:

Data di pubblicazione: 17 May 2023


Lascia il tuo primo commento!

Inserisci il tuo commento