stuttter / wp-term-images Goto Github PK
View Code? Open in Web Editor NEWImages for categories, tags, and other taxonomy terms
Home Page: https://wordpress.org/plugins/wp-term-images/
License: GNU General Public License v2.0
Images for categories, tags, and other taxonomy terms
Home Page: https://wordpress.org/plugins/wp-term-images/
License: GNU General Public License v2.0
The .org repo has version 1.0.0. The latest version in this GitHub repo seems to be 2.0.0.
Among other things, there was a bug fixed in 2.0.0 in the UI::add_column_value() method.
Compare that to WP_Term_Meta_UI ::add_column_value() in the .org repo.
How to use this on tag pages?
To reproduce:
admin-ajax.php
network requestThe issue stems from /assets/js/term-image.js
on Line 113
. The image URL is being inserted instead of the image's attachment ID.
It looks like removing that line fixes it. Since the image is already set, the value doesn't need to be overridden every time someone clicks the quick edit button. I could have overlooked something though.
Cheers ๐
Hi John,
I'm using this plugin with WordPress 4.4-beta1. I've used the code snippet from the readme and found it just returns the meta_value for the term_id. Seeing as the code is echoing the img element I imagine it should return the image URL. I found that the below worked for my purposes:
$image = get_term_meta( 452, 'image', true );
if ( ! empty( $image ) ) {
echo '<img src="' . esc_url( wp_get_attachment_image_url( $image, 'full' ) ) . '" />';
}
I'm very much a PHP n00b, so if this isn't relevant please ignore this issue.
Cheers,
Joel
I'm evaluating using this plugin on a WooCommerce site I'm building.
Woo already has built-in support for adding images to it's product_cat
taxonomy. And I want to add images to Woo's product_tag
taxonomy...and that works fine.
However, there's a conflict with WP_Term_Meta_UI::term_clauses()
and the way Woo alters what is returned by get_terms()
.
Woo provides a drag-and-drop UI on the edit screen for the product_cat
taxonomy that allows a user to specify a sort order for the terms in that tax on the front end. It stores that order order as term meta. By default, it orders to terms in the terms list table by that sort order...as such it adds 'orderby' => 'meta_value_num'
(thru some filter, I forget which at the moment).
Unfortunately, when WP_Term_Meta_UI::term_clauses()
sees 'orderby' => 'meta_value_num'
it joins to the term meta table and alters the where
clause such that only terms with the image
meta key are return. This results in 0 terms being found, even tho the list table realizes there are terms in the taxonomy as evidenced by the highlighted numbers in this screenshot.
[Note: the Image column in that screenshot is Woo's built-in column, and not the one added by this plugin. I have hooked into wp_term_image_get_taxonomies
and restricted the taxonomies this plugin adds the Image column on to Woo's product_tag
tax.]
As a workaround I tried to unhook WP_Term_Meta_UI::term_clauses()
and WP_Term_Meta_UI::get_terms_orderby()
from terms_clauses
and get_terms_orderby
respectively since I don't want the Image column to be sortable anyway. I'm hooking into manage_edit-product_tag_sortable_columns
to remove the Image column this plugin adds from the sortable columns (to match the fact that Woo's built-in Image column for the product_cat
taxonomy isn't sortable). However, since there is no global variable for that object I can't do that.
I bet Woo isn't the only thing that will conflict with allowing 'orderby' => 'meta_value_num'
to cause the join/where modifications that WP_Term_Meta_UI::term_clauses()
does.
Knowing you, I'm sure there's a good reason for having meta_value_num
in $allowed_keys
even tho this plugin doesn't ever key that as an orderby, but for the life of me I can't figure out why :-) This plugin seems to work just fine if I remove meta_value_num
from $allowed_keys
.
...I saw you need some front-end help. Hit me up, maybe I can help. I've been working on some plugins for clients and there would be overlap.
Hi,
Love your new suite of Term Meta plugins.
Was just trying out this term image plugin.
Works well and is nice and clean, but I found the preview image in the admin list view feels teeny tiny at 25 x 25 px - it doesn't feel big enough to be a preview, just lets you know there is an image assigned.
Any reason you don't use a larger preview like the Media list view which is 60 x 60 px?
(I could obvious hook in and override the styling, just wondering if the default is too small)
As a sidenote, I took over management of the Taxonomy Images plugin which used to be managed by Michael Fields but needed some updating for recent versions of WordPress - was still using old media modal. I've not yet moved it over to use term meta but I'd like to make that transition including migration of old data etc. If I were to do that, what are your thoughts on storing the image ID using the same meta key as your plugin so that the 2 plugins could be interchangeable - good idea or bad idea? Certainly would't want to do that without your blessing ๐
Ben
When creating a new term (edit-tags.php), the "Choose Image" button works and the Media Modal displays.
When editing a single term (term.php), the "Choose Image" button does not launch the Media Modal.
WP: v4.5.3
WP Term Images: 0.3.0
If wp_update_term()
is called, to update a term outside of the admin screen, the save_meta function is run from the edit_term
action, causing the image meta to be deleted.
There is a line that says:
// Bail if not updating meta_key
But it doesn't actually bail, proceeding to call $this->set_meta, which then calls delete_term_meta().
Hello, i was inquiring how to get image url i have saw the pull request that add
register_meta( 'term', $this->meta_key, array( 'sanitize_callback' => array($this, 'sanitize_callback'), 'auth_callback' => array($this, 'auth_callback'), 'show_in_rest' => apply_filters("wp_term_image_show_in_rest", true), 'single' => true, ) );
to the class-wp-term-meta-ui.php but all i get is the ID and i have searched for that filter "wp_term_image_show_in_rest" but i couldn't get it, any help??
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.