{"id":255,"date":"2020-02-05T06:36:15","date_gmt":"2020-02-05T06:36:15","guid":{"rendered":"https:\/\/stockpack.co\/blog\/?p=255"},"modified":"2022-11-02T19:09:05","modified_gmt":"2022-11-02T19:09:05","slug":"changing-the-automated-captions","status":"publish","type":"post","link":"https:\/\/stockpack.co\/blog\/changing-the-automated-captions\/","title":{"rendered":"Changing the automated captions"},"content":{"rendered":"\n<p>In the book &#8220;<a href=\"https:\/\/www.amazon.co.uk\/dp\/0321965515\">Don&#8217;t make me think<\/a>&#8221; by Steve Krug, there&#8217;s an explanation about the fact that humans are quite likely to scan an article instead of reading it. <\/p>\n\n\n\n<p>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 <strong>different<\/strong> <em>style<\/em>. <\/p>\n\n\n\n<!--more-->\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"577\" src=\"https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2020\/02\/unique-watermelon-bicycle-stockpack-unsplash-1024x577.jpeg\" alt=\"Unique watermelon bicycle\" class=\"wp-image-257\" srcset=\"https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2020\/02\/unique-watermelon-bicycle-stockpack-unsplash-1024x577.jpeg 1024w, https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2020\/02\/unique-watermelon-bicycle-stockpack-unsplash-300x169.jpeg 300w, https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2020\/02\/unique-watermelon-bicycle-stockpack-unsplash-768x433.jpeg 768w, https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2020\/02\/unique-watermelon-bicycle-stockpack-unsplash-1536x866.jpeg 1536w, https:\/\/stockpack.co\/blog\/wp-content\/uploads\/2020\/02\/unique-watermelon-bicycle-stockpack-unsplash-2048x1155.jpeg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Photo by <a href=\"https:\/\/unsplash.com\/@cristina_gottardi?utm_source=Stockpack&amp;utm_medium=referral&amp;utm_campaign=api-credit\" target=\"_blank\" rel=\"noopener noreferrer\">Cristina Gottardi<\/a> on <a href=\"https:\/\/unsplash.com\/photos\/-22C5tv2hyY?utm_source=StockPack&amp;utm_medium=referral\" target=\"_blank\" rel=\"noopener noreferrer\">Unsplash<\/a><\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Unique captions<\/h2>\n\n\n\n<p>You should aim to be unique as much as possible, as <strong>unique<\/strong> stands out. To support that, we are allowing an easy way to customize the captions in WordPress. <\/p>\n\n\n\n<p>There is a filter available named suggestively: <code>stockpack_caption<\/code><\/p>\n\n\n\n<p>This filter allows translating or modifying the format of the caption. The default WordPress caption looks like this (<em>end lines added for readability<\/em>):<\/p>\n\n\n\n<div style=\"height: 250px; position:relative; margin-bottom: 50px;\" class=\"wp-block-simple-code-block-ace\"><div style=\"position:absolute;top:-20px;right:0px;cursor:pointer\" class=\"copy-simple-code-block\"><svg aria-hidden=\"true\" role=\"img\" focusable=\"false\" class=\"dashicon dashicons-admin-page\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20\" height=\"20\" viewbox=\"0 0 20 20\"><path d=\"M6 15V2h10v13H6zm-1 1h8v2H3V5h2v11z\"><\/path><\/svg><\/div><pre class=\"wp-block-simple-code-block-ace\" style=\"position:absolute;top:0;right:0;bottom:0;left:0\" data-mode=\"html\" data-theme=\"monokai\" data-fontsize=\"14\" data-lines=\"Infinity\" data-showlines=\"true\" data-copy=\"true\">Photo by \n&lt;a href=\"http:\/\/provider.com\/author-url-here\">\n    John Doe\n&lt;\/a> \non \n&lt;a href=\"http:\/\/provider.com\/image-url-goes-here\">\n    FavoriteProvider\n&lt;\/a><\/pre><\/div>\n\n\n\n<p>That is the code, here&#8217;s how that renders: <em>Photo by <a rel=\"noreferrer noopener\" href=\"https:\/\/unsplash.com\/@cristina_gottardi?utm_source=Stockpack&amp;utm_medium=referral&amp;utm_campaign=api-credit\" target=\"_blank\">Cristina Gottardi<\/a> on <a rel=\"noreferrer noopener\" href=\"https:\/\/unsplash.com\/photos\/-22C5tv2hyY?utm_source=StockPack&amp;utm_medium=referral\" target=\"_blank\">Unsplash<\/a><\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Setting your own caption<\/h2>\n\n\n\n<p>If you are not familiar with code, we got you <a href=\"https:\/\/stockpack.co\/blog\/changing-the-automated-captions\/#going-further\">covered<\/a>. Currently, you need to parse that caption, as the data is not available separately, but in time that might change. Here&#8217;s an example:<\/p>\n\n\n\n<div style=\"height: 250px; position:relative; margin-bottom: 50px;\" class=\"wp-block-simple-code-block-ace\"><pre class=\"wp-block-simple-code-block-ace\" style=\"position:absolute;top:0;right:0;bottom:0;left:0\" data-mode=\"php\" data-theme=\"monokai\" data-fontsize=\"14\" data-lines=\"Infinity\" data-showlines=\"true\" data-copy=\"false\">&lt;?php\nfunction change_stockpack_caption_format( $caption, $image ) {\n\tif ( $caption === '' ) {\n\t\treturn $caption;\n\t}\n\t$chunks = explode( \"&lt;\", $caption );\n\t$author= explode( \">\", $chunks[1] );\n\n\n\treturn \"Via &lt;$chunks[3]&lt;\/a> \/ $author[1] \";\n}\n\nadd_filter( 'stockpack_caption', 'change_stockpack_caption_format', 20, 2 );<\/pre><\/div>\n\n\n\n<p>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. <\/p>\n\n\n\n<p>Here&#8217;s how that renders: <em>Via <a rel=\"noreferrer noopener\" href=\"https:\/\/unsplash.com\/photos\/-22C5tv2hyY?utm_source=StockPack&amp;utm_medium=referral\" target=\"_blank\">Unsplash<\/a><\/em> \/ <em>Cristina Gottardi<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"going-further\">Going further<\/h2>\n\n\n\n<p>If you have a specific caption format you need for your WordPress website, and you can&#8217;t get it working on your own, feel free to reach out. We&#8217;d be glad to help. <\/p>\n\n\n\n<p>If you are looking for some tricks to help you stand out with your images check this article: <a href=\"https:\/\/stockpack.co\/blog\/5-simple-image-tricks-that-go-a-long-way-in-wordpress\/\">5 simple image tricks that go a long way in WordPress<\/a><\/p>\n\n\n\n<p> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the book &#8220;Don&#8217;t make me think&#8221; by Steve Krug, there&#8217;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 &#8230; <a title=\"Changing the automated captions\" class=\"read-more\" href=\"https:\/\/stockpack.co\/blog\/changing-the-automated-captions\/\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":256,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,11,7,4,8],"tags":[],"class_list":["post-255","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-documentation","category-help","category-images","category-tutorial","category-wordpress"],"_links":{"self":[{"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/posts\/255","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/comments?post=255"}],"version-history":[{"count":5,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/posts\/255\/revisions"}],"predecessor-version":[{"id":572,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/posts\/255\/revisions\/572"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/media\/256"}],"wp:attachment":[{"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/media?parent=255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/categories?post=255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/tags?post=255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}