Customize Google Image Structured Data Support

Backlight provides a way to embed structured data into your photo website that is used by Google Image to display photo licensing badges. This badges make it easier to find images available for commercial licensing.

One of the fields to supply is the acquire license page. Backlight uses a dedicated page for that. When I looked how stock photo agencies handle this field, I noticed that they link directly to the licensing page of the image. This enhances the user’s experience by simplifying the purchasing flow.

So I’m attempting to do the same thing for Backlight by taking advantage of the customization features provided by phplugins.

Using the single_bottom function, I’m adding the necessary code to create the structured data record which will be used by Google Image search:

function single_bottom( ){
	define("__AUTHOR__", "Daniel Leu");
	define("__COPYHOLDER__", "Daniel Leu");
	define("__LICENSE__", "/licensing");

	$photo = $this->photo;
	$album = $this->album;
	$ph_path = $photo->getUrl('photos');
	$ph_w = $photo->getPhotoWidth();
	$ph_h = $photo->getPhotoHeight();
	$img_title = $photo->hasMetadata(Photo::$PHOTO_TITLE) ? $photo->getMetadata(Photo::$PHOTO_TITLE) : $photo->getFilename();
	$img_caption = $photo->hasMetadata(Photo::$PHOTO_CAPTION) ? " - ". $photo->getMetadata(Photo::$PHOTO_CAPTION) : '';

	echo '
	<script type="application/ld+json">
	{
		"@context": "https://schema.org/",
		"@type": "ImageObject",
		"contentUrl": "'.$ph_path.'",
		"caption": "'.$img_title.$img_caption.'",
		"height": '.$ph_h.',
		"width": '.$ph_w.',
		"representativeOfPage": true,
		"author": "'.__AUTHOR__.'",
		"copyrightHolder": "'.__COPYHOLDER__.'",
		"license": "'.__LICENSE__.'",
		"acquireLicensePage": "'.$photo->getSingleURL().'",
		"thumbnailUrl": "'.$ph_path = $photo->getUrl("thumbnails").'"
	}
	</script>
	';

}
  • If you are already using the single_bottom function, then just add the code XXX of function single_bottom(){XXX} to your existing single_bottom function.
  • Set the values for __AUTHOR__, __COPYHOLDER__, and __LICENSE__ accordingly.
  • Please note that I’m concatenating the photo title and caption fields separated by a single dash to provide more data to Google
  • If you prefer the link to go to the parent album you can use “acquireLicensePage”: “‘.$photo->getAlbumURL().'”,

Once you have added this to your site, you can easyly verify that it works by going to https://search.google.com/test/rich-results and providing a link to the single-image page of one of your images.

I hope this feature helps you to make it easier to closed licensing deals originating from Google Images search. Good Luck!


Did you like this post? Did you use the given code? Please consider supporting me by buying me a coffee!

Buy Me A Coffee


Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

Web Design Consulting

Do you need help designing your web site or getting Backlight working the way you want? Contact me to discuss your idea or project.


Buy me a Coffee

If you like what I share here, please consider buying me a coffee or a print. This helps keeping me motivated to continue posting. Thank you!

Buy Me A Coffee

Categories