{"id":36936,"date":"2015-06-15T20:05:32","date_gmt":"2015-06-15T20:05:32","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/sf-taxonomy-thumbnail\/"},"modified":"2016-05-30T18:34:53","modified_gmt":"2016-05-30T18:34:53","slug":"sf-taxonomy-thumbnail","status":"publish","type":"plugin","link":"https:\/\/gl.wordpress.org\/plugins\/sf-taxonomy-thumbnail\/","author":7167877,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.3","stable_tag":"trunk","tested":"4.5.33","requires":"3.5","requires_php":"","requires_plugins":"","header_name":"SF Taxonomy Thumbnail","header_author":"Gr\u00e9gory Viguier","header_description":"","assets_banners_color":"d2b5b8","last_updated":"2016-05-30 18:34:53","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"https:\/\/www.screenfeed.fr\/plugin-wp\/taxonomy-thumbnail\/","header_author_uri":"https:\/\/www.screenfeed.fr\/greg\/","rating":5,"author_block_rating":0,"active_installs":4000,"downloads":50807,"num_ratings":10,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":[],"upgrade_notice":{"":"<p>If you use <em>Meta for Taxonomies<\/em> plugin, you will need this version when WordPress 4.4 comes out.<\/p>"},"ratings":{"1":0,"2":0,"3":0,"4":0,"5":"11"},"assets_icons":{"icon-128x128.png":{"filename":"icon-128x128.png","revision":"1181360","resolution":"128x128","location":"assets"},"icon-256x256.png":{"filename":"icon-256x256.png","revision":"1181360","resolution":"256x256","location":"assets"},"icon.svg":{"filename":"icon.svg","revision":"1181360","resolution":"","location":"assets"}},"assets_banners":{"banner-772x250-rtl.jpg":{"filename":"banner-772x250-rtl.jpg","revision":"1286672","resolution":"772x250","location":"assets"},"banner-772x250.jpg":{"filename":"banner-772x250.jpg","revision":"1286672","resolution":"772x250","location":"assets"}},"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.1"],"block_files":[],"assets_screenshots":{"screenshot-1.png":{"filename":"screenshot-1.png","revision":"1181380","resolution":"1","location":"assets"},"screenshot-2.png":{"filename":"screenshot-2.png","revision":"1181380","resolution":"2","location":"assets"}},"screenshots":{"1":"Create a new category an assign a thumbnail.","2":"Change or remove the thumbnail from the category."},"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[89,2985,133,91,1326],"plugin_category":[50,57],"plugin_contributors":[78484],"plugin_business_model":[],"class_list":["post-36936","plugin","type-plugin","status-publish","hentry","plugin_tags-category","plugin_tags-dev","plugin_tags-image","plugin_tags-taxonomy","plugin_tags-thumbnail","plugin_category-media","plugin_category-taxonomy","plugin_contributors-greglone","plugin_committers-greglone"],"banners":{"banner":"https:\/\/ps.w.org\/sf-taxonomy-thumbnail\/assets\/banner-772x250.jpg?rev=1286672","banner_2x":false,"banner_rtl":false,"banner_2x_rtl":false},"icons":{"svg":"https:\/\/ps.w.org\/sf-taxonomy-thumbnail\/assets\/icon.svg?rev=1181360","icon":"https:\/\/ps.w.org\/sf-taxonomy-thumbnail\/assets\/icon.svg?rev=1181360","icon_2x":false,"generated":false},"screenshots":[{"src":"https:\/\/ps.w.org\/sf-taxonomy-thumbnail\/assets\/screenshot-1.png?rev=1181380","caption":"Create a new category an assign a thumbnail."},{"src":"https:\/\/ps.w.org\/sf-taxonomy-thumbnail\/assets\/screenshot-2.png?rev=1181380","caption":"Change or remove the thumbnail from the category."}],"raw_content":"<!--section=description-->\n<p>This plugin is meant for developers, it allows to attach a thumbnail to taxonomy terms.<\/p>\n\n<h4>UI for setting the thumbnails<\/h4>\n\n<p>The thumbnail can be added on term creation or later on the term edition page.<br \/>\nThe terms list has a column displaying the current thumbnail (so far, no specific action here).<br \/>\nThe plugin uses the \"new\" media window (the one used since WP 3.5), not the old thickbox.<br \/>\nI made some extra efforts to enhance accessibility. I'm not an a11y expert but the UI is not only a \"Add thumbnail\" button. For instance, the new <code>wp.a11y.speak()<\/code> is used when available. Please give me feedback if you think it can be improved.<br \/>\nWorks with or without JavaScript.<br \/>\nIf JavaScript is enabled, thumbnails are set via ajax in the term edition window, no need to update the term.<br \/>\nBy default, the UI is displayed for all public taxonomies, but this can be filtered that way:<\/p>\n\n<pre><code>add_filter( 'sftth_taxonomies', 'my_taxonomies_with_thumbnail' );\n\nfunction my_taxonomies_with_thumbnail( $taxonomies ) {\n    unset( $taxonomies['post_tag'] );\n    $taxonomies['my_custom_tax'] = 'my_custom_tax';\n    return $taxonomies;\n}\n<\/code><\/pre>\n\n<h4>Template tags<\/h4>\n\n<p>Find them in <code>inc\/template-tags.php<\/code>.<br \/>\n<strong>Important note: for WP 4.4+, these functions use <code>term_id<\/code>. For WP &lt; 4.4, they use <code>term_taxonomy_id<\/code>.<\/strong><br \/>\nI tried to mimic the post thumbnail functions:<\/p>\n\n<ol>\n<li><code>get_term_thumbnail_id( $term_id )<\/code>: Retrieve term thumbnail ID.<\/li>\n<li><code>has_term_thumbnail( $term_id )<\/code>: Check if a term has a thumbnail attached to it.<\/li>\n<li><code>the_term_thumbnail( $term_id, $size = 'post-thumbnail', $attr = '' )<\/code>: Display the term thumbnail.<\/li>\n<li><code>get_term_thumbnail( $term_id, $size = 'post-thumbnail', $attr = '' )<\/code>: Retrieve the term thumbnail.<\/li>\n<li><code>set_term_thumbnail( $term_id, $thumbnail_id )<\/code>: Set a term thumbnail.<\/li>\n<li><code>delete_term_thumbnail( $term_id )<\/code>: Detach a thumbnail from a term.<\/li>\n<\/ol>\n\n<h4>Store the data<\/h4>\n\n<p>From WordPress 4.4, the term metas API is used.<br \/>\nBelow WordPress 4.4, there are two ways to store the thumbnail IDs:<\/p>\n\n<ol>\n<li>Use term metas with the plugin <a href=\"https:\/\/wordpress.org\/plugins\/meta-for-taxonomies\/\">Meta for Taxonomies<\/a>.<\/li>\n<li>Use an option (an array association of <code>term_taxonomy_id<\/code> =&gt; <code>thumbnail_id<\/code> integers). The option name can be customized by defining the constant <code>SFTTH_OPTION_NAME<\/code> in <code>wp-config.php<\/code>.<\/li>\n<\/ol>\n\n<h4>Get terms<\/h4>\n\n<p>Use <code>get_terms()<\/code> with a specific parameter to retrieve only terms with a thumbnail:<\/p>\n\n<pre><code>$terms = get_terms( array(\n    'with_thumbnail' =&gt; true,\n) );\n<\/code><\/pre>\n\n<p>From WordPress 4.4, you can also use a small helper to build your meta query:<\/p>\n\n<pre><code>$terms = get_terms( array(\n    'meta_query' =&gt; array(\n        'relation' =&gt; 'AND',\n        array(\n            \/\/ Any meta query.\n        ),\n        sftth_meta_query(),\n    ),\n) );\n<\/code><\/pre>\n\n<p>Below WordPress 4.4, if you use the plugin <em>Meta for Taxonomies<\/em>, you should always cache thumbnails.<br \/>\nWhen using <code>'with_thumbnail' =&gt; false<\/code> you will retrieve all terms, even those without a thumbnail, but the thumbnails will be cached, saving calls to the database later:<\/p>\n\n<pre><code>$terms = get_terms( array(\n    'with_thumbnail' =&gt; false,\n) );\n<\/code><\/pre>\n\n<h4>Uninstall<\/h4>\n\n<p>When uninstalling the plugin, you can decide to not delete the thumbnails, simply define a constant in <code>wp-config.php<\/code>:<\/p>\n\n<pre><code>define( 'SFTTH_KEEP_DATA', true );\n<\/code><\/pre>\n\n<h4>Translations<\/h4>\n\n<ul>\n<li>US English<\/li>\n<li>French<\/li>\n<\/ul>\n\n<h4>Requirements<\/h4>\n\n<p>Should work starting from WP 3.5, but tested only in WP 4.2.2+ so far.<\/p>\n\n<h4>Credits<\/h4>\n\n<p>Photo used for the banner by <a href=\"https:\/\/www.flickr.com\/photos\/n1colas\/2598073727\/\">Nicolas Janik<\/a> (<a href=\"https:\/\/creativecommons.org\/licenses\/by\/2.0\/\">CC BY 2.0<\/a>).<\/p>\n\n<!--section=installation-->\n<ol>\n<li>Extract the plugin folder from the downloaded ZIP file.<\/li>\n<li>Upload the <code>sf-taxonomy-thumbnail<\/code> folder to your <code>\/wp-content\/plugins\/<\/code> directory.<\/li>\n<li>Activate the plugin from the \"Plugins\" page.<\/li>\n<li>Below WordPress 4.4, if you want to use term metas instead of an option, install the plugin <a href=\"https:\/\/wordpress.org\/plugins\/meta-for-taxonomies\/\">Meta for Taxonomies<\/a>.<\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt>Why should I use the plugin *Meta for Taxonomies*?<\/dt>\n<dd><p>If you use WordPress 4.4 or greater you don't need to.<br \/>\nOtherwise, I think it's the proper way to store this kind of data. Post thumbnails are stored in post metas, right? So term thumbnails should be stored in term metas.<br \/>\nBut it requires a plugin, WordPress does not provide a term metas system before 4.4. On the other hand, I don't want to force you to use a dependency, so I wanted my plugin to also work without it.<\/p><\/dd>\n<dt>Any plan for a settings page where I can choose the taxonomies?<\/dt>\n<dd><p>Nope, it will not happen, imho there is no point to do so.<\/p><\/dd>\n<dt>Other questions?<\/dt>\n<dd><p>Eventually, try the <a href=\"https:\/\/wordpress.org\/support\/plugin\/sf-taxonomy-thumbnail\">WordPress support forum<\/a>.<\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>1.3<\/h4>\n\n<ul>\n<li>2016\/05\/30<\/li>\n<li>The plugin now works with svg files (using svg files require an adequate plugin).<\/li>\n<li>Improved code docs.<\/li>\n<\/ul>\n\n<h4>1.2.2<\/h4>\n\n<ul>\n<li>2016\/05\/30<\/li>\n<li>Fixed a bug that prevented the use of SVG as thumbnail.<\/li>\n<\/ul>\n\n<h4>1.2.1<\/h4>\n\n<ul>\n<li>2016\/01\/31<\/li>\n<li>Bugfix in uninstallation process: term metas wouldn't be deleted with the new WordPress API. Props Ghislain Phu.<\/li>\n<\/ul>\n\n<h4>1.2<\/h4>\n\n<ul>\n<li>2015\/11\/01<\/li>\n<li>Ready for WordPress 4.4: the plugin will use the new term metas API and will no longer use <em>Meta for Taxonomies<\/em> plugin. <strong>Developers, be aware that with WP 4.4+ the template tags do not use <code>term_taxonomy_id<\/code> anymore, but <code>term_id<\/code> instead.<\/strong><\/li>\n<li>Migrate to WordPress 4.4: when the site is updated to WP 4.4, the plugin automatically migrate the old data (stored in an option or by <em>Meta for Taxonomies<\/em>) to the new term metas table, convert <code>term_taxonomy_id<\/code>s into <code>term_id<\/code>s, and delete old data (only the plugin data of course). Then if you used <em>Meta for Taxonomies<\/em>, it can be uninstalled afterward. <strong>Side note: in case <em>Meta for Taxonomies<\/em> is not updated by then, you should deactivate it BEFORE updating to WordPress 4.4 (it is not compatible with WP 4.4 yet, and will trigger a fatal error).<\/strong><\/li>\n<li>New: when an image attachment is trashed or deleted, the related meta is also removed.<\/li>\n<li>Lots of docs have been added or updated.<\/li>\n<li>It's a bit late now but there are new tools to migrate data between option and <em>Meta for Taxonomies<\/em>. See <code>inc\/migrate.php<\/code>.<\/li>\n<\/ul>\n\n<h4>1.1<\/h4>\n\n<ul>\n<li>2015\/09\/20<\/li>\n<li>Move the thumbnail column after the term name. Since WP 4.3 there is a concept of <em>primary column<\/em>: if the thumbnail is not displayed AFTER this primary column (the term name), it will break the row layout on screens &lt; 782px.<\/li>\n<li>Code cleanup.<\/li>\n<\/ul>\n\n<h4>1.0<\/h4>\n\n<ul>\n<li>2015\/06\/11<\/li>\n<li>Initial release.<\/li>\n<\/ul>","raw_excerpt":"Add a thumbnail to your taxonomy terms.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/gl.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/36936","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gl.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/gl.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/gl.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=36936"}],"author":[{"embeddable":true,"href":"https:\/\/gl.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/greglone"}],"wp:attachment":[{"href":"https:\/\/gl.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=36936"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/gl.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=36936"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/gl.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=36936"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/gl.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=36936"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/gl.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=36936"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/gl.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=36936"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}