Changing the automated captions

In the book “Don’t make me think” by Steve Krug, there’s an explanation about the fact that humans are quite likely to scan an article instead of reading it.

While scanning your article the parts that stand out are the ones that are more unique. That includes images and captions, as captions are normally in a different style.

Unique watermelon bicycle
Photo by Cristina Gottardi on Unsplash

Unique captions

You should aim to be unique as much as possible, as unique stands out. To support that, we are allowing an easy way to customize the captions in WordPress.

There is a filter available named suggestively: stockpack_caption

This filter allows translating or modifying the format of the caption. The default WordPress caption looks like this (end lines added for readability):

Photo by 
<a href="">
    John Doe
<a href="">

That is the code, here’s how that renders: Photo by Cristina Gottardi on Unsplash

Setting your own caption

If you are not familiar with code, we got you covered. Currently, you need to parse that caption, as the data is not available separately, but in time that might change. Here’s an example:

function change_stockpack_caption_format( $caption, $image ) {
	if ( $caption === '' ) {
		return $caption;
	$chunks = explode( "<", $caption );
	$author= explode( ">", $chunks[1] );

	return "Via <$chunks[3]</a> / $author[1] ";

add_filter( 'stockpack_caption', 'change_stockpack_caption_format', 20, 2 );

This function removed the author URL, and displays only the image URL, while mentioning the author. Since users can easily get the author from the image URL this should be just fine.

Here’s how that renders: Via Unsplash / Cristina Gottardi

Going further

If you have a specific caption format you need for your WordPress website, and you can’t get it working on your own, feel free to reach out. We’d be glad to help.

If you are looking for some tricks to help you stand out with your images check this article: 5 simple image tricks that go a long way in WordPress

Leave a Comment