Media Tags
Media-Tags 3.0 Released
I’m proud to say I’ve finally released Media-Tags 3.0 to the general public and is available in the WordPress plugin repository http://wordpress.org/extend/plugins/media-tags/. Thanks to all who contributed ideas, bug reports and support in this milestone development. And my apologies for taking so long to get this out.
This plugin contains many new features. Some highlighted items are:
- Bulk Administration of media items This feature on both the Media > Library and Media Upload popup for the Post admin screen allow you to assign/remove Media-Tags to a selected group of media items. In previous versions you would need to edit each media item.
- Roles management Under the Media-Tags Settings panel is a new Roles management panel. This panel allows you to fine tune the access by individual users.
- Internationalization This is a much needed and requested features. Now all text handled by the plugin are using the WordPress i18n hooks to support translation into other languages.
- Removed over 1000 lines of custom code This old code was used to provide basic functionality for the tagging and URL rewrites. Since WordPress core functions have progressed over the last two years this custom code is no longer needed. This means the plugin will run cleaner and is more stable than previous releases.
- Better support for WordPress standard Taxonomy templates In the past the plugin has supported a custom theme template, mediatag.php. The plugin now support the more standard WordPress templates taxonomy-media-tags.php.
- A new Help section This new Help section provides many topics from general use to shortcodes tricks to template files support questions. Check it out.
- Many other features have been added. Too many to mention here.
What does the Media Tags plugin do? And why do I need it?
Simply put the Media-Tags plugin allow you assign tags to your uploaded media (i.e. Image, document, etc.) much like the way you assign tags to post in WordPress. The Media-Tags plugin add new fields to the Media Upload popup on the Pages and Posts editor as well as the edit form on the Media Library editor form.
The Media-Tags plugins works by creating a custom Taxonomy using the built-in WordPress Taxonomy support framework. This Taxonomy framework is the same system used by Categories, Post tags, etc. This means the Media-Tags plugin is not creating new database tables in your system or storing tons of data into your wp_options table.
Using Media-Tags to tag media
I know the previous line may seem like I’m talking in circles. Let me explain.
Once you have media items tagged you can access then with some simple PHP functions via your templates like:
1 | get_attachments_by_media_tags() |
This function takes a number of possible arguments:
media_tags (Required) – This is a comma separated list of tag slugs used to filter the possible selections. At least one media tag slug is required.
media_types (Optional) – This is a comma separated list of media types pdf, jpg, gif, etc.
post_parent (Optional) – This will limit the media items selected to the given post/page ID. Only a single ID can currently be used.
search_by (Options) – default ‘slug’. Allows searching by other methods. At this time only ‘slug’ is supported.
numberposts (Optional) – default ‘-1′. Specify the number of items to return. Works much like get_posts();
orderby (Optional) – default ‘menu_order’. Specify display ordering.
order (Optional) – default ‘DESC’. Specify display ordering.
offset (Optional) – default ’0′. Allow skipping the number of media items returned. Good for handling paging.
return_type (Optional) – default ”. Be default the function returns a raw PHP array. you then need to handle the display of items. Passing ‘li’ will force the function to return the items as an list elements.
tags_compare (Optional) – default ‘OR’. When using multiple elements in the ‘media_tags’ argument this tells the function how they should be compared. For example if you want items that are tagged either ‘vacation’ OR ‘hawaii’. The other possible value here is ‘AND’ to get items that are tagged for both values.
display_item_callback – By default not used. If set this would be a user defined function. A call to this user function will be made for each item found. See the function ‘default_item_callback’ in the plugin file mediatags_shortcodes.php.
call_source – Used internally by the function. Is set when using the shortcode part of the plugin.
An examples of using this function are:
1 2 3 4 | $media_items = get_attachments_by_media_tags('media_tags=vacation,hawaii&numberposts=10&return_type=li'); if ($media_items) { echo "<ul>". $media_items. "</ul>"; } |
Media-Tags uses WP Shortcodes.
I’m sure when reading the above many readers growned about needed to code in PHP. Well the good news is Media-Tags also supports the WP shortcode system. The shortcode equivalent for the previous example would be the following.
1 | [media-tags media_tags="vacation,hawaii" numberposts="10"] |
When using the shortcode the default output is a ‘li’ for list elements. But you can also use the ‘display_item_callback’ parameter to call a user defined function. Use of the shortcode also provides more parameters that let you control the output.
before_list (Optional) – default is ‘<ul>’. Using this parameter you can pass in your own list wrapper ‘ul’, ‘ol’ and provide needed CSS class and ID settings.
after_list (Optional) – default is ‘</ul>.
post_parent (Optional) – here the value ‘this’ can be used to designate the current global post/page ID.
Pretty cool!
Template function
The Media-Tags plugin also supports a wide range is available template function you can use in your theme templates. For example to list out the Media-Tags tag cloud which is very similar to the Post tags tag cloud you would add the following to your sidebar.php
1 | mediatags_cloud(); |
This template function is actually just a wrapper around the WordPress built-in wp_tag_cloud function. As part of the wrapper we specify using the Media-Tags Taxonomy instead of the default Post tags. To find out what options are available for the mediatags_cloud function just follow the information for wp_tag_cloud.
Another handy function is ‘get_mediatag_link’. This function takes one required argument. The argument is the ID of the Media-Tag. This is link the Category or Tag ID.
Yet another function is ‘the_mediatags’. This function is patterned after the ‘the_tags’ function provided by WordPress. The ‘the_mediatags’ function will output a comma-seperated setup of values for the current post item.
Look for a complete template functions reference coming soon.
Media-Tags Permalink Base
The Media-Tags plugin allows you to setup archives to display the tagged media items. Think of this similar to Category, Tag or Author archives. By default the Media-Tags plugin assigns a special URL parameter where you pass in the Media-Tag slus like ‘http://www.yoursite.com/media-tags/
Media-Tags Archive Templates
As mentioned the Media-Tags plugin allows for display of tagged media items in an archive much like Categories, Post Tags and Authors. To support this Media-Tags also support the use of specific theme template files for displaying media-tag items. Following the built-in WordPress template hierarchy when you view an archive if the archive.php theme file is present it will be used instead of the index.php. With the Media-Tags plugin if you have a file in your theme folder named ‘mediatag.php’ it will be used before the archive.php or index.php. Also you can define a specific Media-Tag archive to control the display on a specific Media-Tag ID. For example you want your media items from Media-Tag 12 to look different. You can create a theme file ‘mediatag-12.php’ to display those items differently than the normal media items.
Media-Tags Archive RSS Feed
As part of these Media-Tags archives you also have available an RSS feed which will allow users to add to their feed reader to track new information you tag using Media-Tags. Following the previous example on the archive for media items tagged as ‘vacation’. The archive URL will appears be default as http://yoursite.com/media-tags/vacation The RSS2 feed for this Media-Tag item will be http://yoursite.com/media-tags/vacation/feed/
Export and Import
Since Media-Tags works using the built-in Taxonomy system provided by WordPress it also handles the export of your Media-Tag information via the Tools -> Export options under wp-admin. This allows you to transfer you site content via the WordPress Export process to another WordPress instance where you can import the XML file.
Widgets
The Media-Tags plugin does not contain or support widgets itself. But other developers have put together some Widgets you can download and play with. Note these Widgets depend on Media-Tags being installed.
- Media Widget (http://wordpress.org/extend/plugins/media-widget/)
- Tag Gallery (http://wordpress.org/extend/plugins/tag-gallery/)
Download
As is customary the only place you should ever download released plugins is via the WordPress official plugin repository.
Download the new Media-Tags plugin


July 21st, 2009 at 11:43 am
Thanks for your work on this new release! Unfortunately, I’ve been unable to get shortcode working… I want to show all the picture attachments for a person on his post, so I use this syntax:
[media-tags media_tags="person-name" before_list="" after_list=""]
And nothing happens. Am I doing something wrong?
Also, on the media tag admin page, when I click on the number of attachments I get nothing, like there were no one.
Again, thanks for your work and I hope the plugin ends up working for me too
July 21st, 2009 at 11:54 am
Carlos Will look into the shortcodes ASAP for you. Can you tell me what version of WordPress you are using?
As far as the number count on the new Media Tags admin interface this is the number from WP on the number of items with that tag. In the core WP this Taxonomy is tied to Posts and should take you to the Post listing page in wp-admin. The problem I can’t seem to solve with the number is that in the media-tagd world the count is Posts and Pages. I might just remove the link. I left it originally because it provides and indicator to the user how many times a media tag is used. Thus facilitating deleting dead media tags.
July 21st, 2009 at 12:33 pm
Hi Paul. I’m using the latest, WordPress 2.8.2. And regarding the number count link, do what you think is best. Thanks a lot for the quick answer.
July 22nd, 2009 at 6:27 am
Hi Paul
Firstly – Great Plug-in
I “Think” it is exactly what I am looking for, so I can categorize downlaodable documents.
I am a TOTAL Newbie (learn from a lot of trial and error). Do you have an example mediatags.php file that I can look at to learn how to modify my own?
Thanks Paul
Cheers
Ken
July 22nd, 2009 at 7:36 am
@Ken Hobson: If you take the default theme archive.php and copy it to mediatag.php in your current theme folder you should have a good start. There are no special tags needed for the template file. Just your normal loop function.
July 23rd, 2009 at 7:43 pm
Just pushed version 2.1.1 of Media-Tags to the WordPress repository. This new version (second one today) fixes a set of bug with the relative paths used to load the needed JavaScript libraries when WordPress is not installed into the site root.
Thanks to Ilan Y. Cohen for pointing out the error and providing suggestions on this fix as well as some other related modifications.
July 23rd, 2009 at 8:34 pm
Hi, I have only a trouble.
When I’m using this new taxonomy, it’s only working when I’m logged on my wordpress blog. When I logoff and try to access (for example: http://www.virtual.ufpb.br/wordpress/media-tags/biblioteca/) it’s saying that not found. :/
Anyway, thanks!
July 24th, 2009 at 4:27 am
I want the use the thumbnails and the link behaviour of the default [gallery] shortcode for a set of images I tagged with media-tags. I am already spending 4 hours to find a decent solution for this. I don’t think Media Tags can help me with this. No parameter displaying thumbnails or define link behaviour.
July 24th, 2009 at 7:27 am
@Francisco Ernesto Teixeira: Strange. Yes I just tried this on a fresh WP 2.8.2 install with a handfull of media-tag entries. Confirmed that this causes the 404 to be display. Ok. tracing the code. Hope to have a new patch up soon. Thanks for bringing this up.
July 24th, 2009 at 7:28 am
@Matthijs: Hmm. Have not thought about integration on interplay with the WP gallery code. When I have some time I’ll try and find a suggestion.
July 24th, 2009 at 8:31 am
Just pushed a new version of the media-tags plugin, 2.1.2 to the WordPress repository. This should solve the issue reported by Francisco Ernesto Teixeira http://www.codehooligans.com/2009/07/15/media-tags-20-released/#comment-42663
August 5th, 2009 at 5:37 am
Hello, like to say – it’s very nice plugin.
Few bugs that occured to me:
When gallery is searched it is done by //$get_terms_args['search'] = $search_term;
so slugs and NAMES dont match, cause $search_term is slug, and ['search'] do it by name
I got around with: $get_terms_args['slug'] = $search_term;
#2
It appears that if media-tag slug is same as some categories slug – $term_id in TERM_TAXONOMY will be the same as categories (wrong), so it can’t be filtered right.
What do you think would be quick fix for that?
Maybe prefix to slug?
Thanks, I appriciate your work.
Jozik
August 5th, 2009 at 8:24 am
@Jozik: Thanks for the comment. I’m not really sure where I pulled the get_terms_args['search'] from. Must have been some other plugins I was looking at. You are correct the correct parameter should be ‘slug’.
I’m not sure on the second item. Will need to research.
August 6th, 2009 at 8:02 am
Paul, et. al,
This is a great plugin, and it’s theory should be integrated into the WP core — really great work.
One question, though:
On my mediatag.php archive page, how do I get the title of the current viewed tag to automatically appear?
e.g., at the top of the page I want it to say, “Images tagged as [dynamic name of media-tag requested]“.
For normal tag or category archive pages, there is a function, single_cat_title() and single_tag_title()
For now, I am just parsing the URL and extracting the title from there, but it’s not a pretty solution.
Once again, thank you!
August 6th, 2009 at 9:29 am
Carlos: Excellent question. Guess I forgot that in the template functions. Here is a little code snippet. I’ll be included this change in the next release next week of the Media Tags plugin. Thanks Carlos for the comment and suggestion.
Please add this to the bottom of the media tags file ‘mediatags_template_functions.php’.
function single_mediatag_title()
{
$mediatag_var = get_query_var(MEDIA_TAGS_QUERYVAR);
if ($mediatag_var) {
$mediatag_term = is_term( $mediatag_var, MEDIA_TAGS_TAXONOMY );
if (isset($mediatag_term['term_id'])) {
$media_tag = &get_term( $mediatag_term['term_id'], MEDIA_TAGS_TAXONOMY );
echo $media_tag->name;
}
}
}
Then you can call if from your mediatag.php template file like this (Or add the code to your archive.php provided from WordPress):
Posts Tagged ‘’
August 6th, 2009 at 11:28 am
Thanks Paul… worked perfectly!
Once again, great work with the plugin… beautifully executed.
August 6th, 2009 at 2:51 pm
Just upgraded to 2.1.3 – everything seems to work fine.
Thanks!
August 6th, 2009 at 3:30 pm
Thank you for your help.
August 14th, 2009 at 10:56 am
Great plugin , do you have any plans to add a tags col on the main lib page, like post?
August 14th, 2009 at 11:14 am
@John Turner: not sure I follow your message. I do plan to put in a Media Tag Cloud template function possibly this weekend. Does that answer your question? Sorry not sure what you meant be ‘tag col’.
August 21st, 2009 at 9:44 am
returns the tags without the proper syntax, i.e.
restoration
What would be the proper fix for a valid link? Thanks for a very needed plugin!
August 21st, 2009 at 9:45 am
August 21st, 2009 at 9:48 am
@David Radovanovic: That is strange. Appear it is not including the ‘/’ between your domain and the ‘media-tags’ permalink prefix. If you are running the plugin version 2.2 (the latest) you should be able to adjust this under Settings -> Permalinks. The new version of the plugin adds an input field at the very bottom and defaults to ‘media-tags’. Change your value to include the ‘/’ as in ‘/media-tags’.
August 21st, 2009 at 10:45 am
even with the /media in permalinks, “/” still is missing:
http://www.architecturalwebdesign.com/?attachment_id=90
August 21st, 2009 at 2:08 pm
Just wanted to give you a big thank you! I upgraded to 2.2 with no issues.
My biggest want and desire would be a way to bulk-manage tags, where we could use the checkboxes on the Media admin page to add to a category.
Thanks again – fabulous work!
August 21st, 2009 at 2:30 pm
If anyone is interested in the details of the solution for David let me know. I’ve patched the plugin code on his site and will include the patch in the next release of the plugin. Don’t really see a point in providing another release this week for such a minor fix. If your site is running the default permalink structure and you use the Media Tags plugin feel free to leave a comment here and I will pass you the changed files. Or just sit tight and wait for the next release.
August 21st, 2009 at 2:32 pm
@Ami: Thank for the comment and complements on the plugin. I really do enjoy this plugin there is just so much functionality built into it.
I’ve been trying to think of some bulk update or bulk assign logic and screen. If you have any suggestions please state them here. Would love some ideas.
August 21st, 2009 at 3:00 pm
Hi Paul! You are so incredibly responsive, thank you!
Two things, first to answer our prior convo: there’s a plugin that does this reasonably well for categories, called batch categories. Here’s the link: http://robm.me.uk/projects/plugins/wordpress/batch-categories/
Another idea would be on the Media Library screen, you could try to utilize the bulk actions dropdown to do an add to tags, or add a similar dropdown with the existing media tags where the “apply” button works. Sorry if neither of these solutions is possible, it’s just a couple of ideas I had.
Secondly, I went to the permalinks tab and changed it from ‘media-tags’ to ‘galleries’, and it’s still showing the archives at http://www.testsite.com/media-tags/tag instead of http://www.testsite.com/galleries/tag
Any ideas? THANK YOU!
August 21st, 2009 at 3:02 pm
Oh, and one other thing, there’s a plugin called “Simple Tags” that auto-assigns tags to a post based upon words in the post. I wonder if some of that logic could auto-assign media tags based upon words in the file name of the photo? Pie in the sky, I know, but I thought I’d throw it out there!
http://wordpress.org/extend/plugins/simple-tags
August 22nd, 2009 at 2:25 pm
Sorry, let me clarify, If you click on post you’ll see a “Tags” column on the list view, I was wondering if you had any plans of adding a “Tags” column on the Media Library list view. If not, I’ll see if I can add it and contribute the code back.
August 22nd, 2009 at 2:44 pm
@John: Ah, Yes do plan on doing this eventually. Though not sure the Media list has hooks like the Pages and Posts lists. It’s on my list for an upcoming release.
August 23rd, 2009 at 10:59 pm
Hey Paul,
I believe there is a small bug in the latest release (2.2). Lines 343 to 349 of media_tags.php should not be commented out, otherwise all posts are returned in the loop.
Thanks for the plugin, it is excellent.
August 24th, 2009 at 2:31 am
I’m using 2.2 version of your plugin and I’m having problems with my custom templates. I’ve hacked the site quite a bit and added some extra features with jQuery (1.3.2) and jQuery timers (1.1.3).
If I activate your plugin, jQuery timers fail to work (“jquery.timer is undefined”), if I deactivate the plugin everything works as it should.
August 24th, 2009 at 2:41 am
Ok, debuged it – had to move my includes under , since media-tags includes jquery in the head and that fizzles my other plugins. Perhaps you could alert other authors that your plugin needs jquery to work, as I’ve been digging for two days why my functions magically stopped working. (mental note: do a single change at a time, you’ll debug easier:))
August 24th, 2009 at 2:43 am
blog stripped my:
…under “wp _ head();” …
August 24th, 2009 at 8:05 am
@Brad Touesnard: Thanks for the comment. Those lines are purposely commented out. In the original version of the Media-Tags plugin the returned items was limited to the related parent post. Since version 2.0 of the Media-Tags plugin by not limited to returning just the items for the given post (in the loop). If you do want to limit the returned items you can pass the ‘post_patent’ argument into the function call to get_attachments_by_media_tags(); or you can use the legacy function (used in pre-2.0), get_media_by_tag() which will automatically set the ‘post_parent’ parameter.
August 24th, 2009 at 8:23 am
@Luka Birsa: Thanks for the comment on this. I’m assuming you are referring to jQuery used for the front-end theme view and not the wp-admin view. At first I blew this off until I checked my code. Seems I am including jQuery on the front-end instead of just the wp-admin. This will be fixed in the next release this coming week. Here are the details of the bug.
If you open media_tags.php and view lines 74-82 you will see the line ‘wp_enqueue_script(‘jquery-form’);’ This is the only reference to jQuery in the entire plugin. The problem is this call is in the wrong place. The ‘init()’ is used by the theme ‘wp_head()’ function so as you are aware this means will insert jQuery into the front-end head. The change I just made was to move the ‘wp_enqueue_script(‘jquery-form’);’ line into ‘admin_init()’ function lines 84-88.
And just to be clean on this. The Media-Tags plugin does not require jQuery for any display for the front-end of the site. However the plugin does use jQuery for many of the screens in wp-admin. For this jQuery is already included. The jquery-form call is needed on the Media-Tags management screen for the Quick Edit function.
Finally thanks for the tip/advice on the ‘do a single change at a time, you’ll debug easier’.
August 24th, 2009 at 12:36 pm
hi paul! just checked in and wanted to let you know there’s a comment in moderation to go above the one posted as comment #3 now. it has some ideas for you about the tagging. thanks!
August 24th, 2009 at 12:37 pm
@Ami: Ah. Yeah didn’t see that one held up. You have now been white listed.
As always thanks for the comments.
August 24th, 2009 at 12:40 pm
@Ami: Hmm. Well maybe not. The comment seems to be stuck in my Pending group. Even though I’m approved it multiple time. Argh!!!
August 24th, 2009 at 12:46 pm
thanks! looks like it’s there now.
hopefully the ideas on tagging help!
any clue on my page permalink not working? i’m happy to hardcode it into the php file if that’s easier, don’t really need the option.
and also, wanted to let you know i’m going to donate to you for this, you’ve put so much work into it and i’m so appreciative. i don’t have much at this point, but hopefully every little bit helps!
August 24th, 2009 at 12:49 pm
Paul,
Great update…. many thanks as always.
Is there any way (be it through additional features, or built into wordpress) to allow people to search through the tags?
I know I can allow people to search within specific categories or tags with hidden fields in the search form element, (e.g., )
…but can I filter for JUST media-tags?
Great work as always!
-Carlos
August 24th, 2009 at 12:52 pm
@Ami: Yes, those suggestions help. I’m looking into the Bulk option today.
As for your issue with the permalink slug not working it should work. If not open the file mediatags_config.php in the plugins tree. You will see the lines 8-12.
$mediatag_base = get_option(‘mediatag_base’);
// Need to come up with validation logic here.
if (!$mediatag_base)
$mediatag_base = “media-tags”;
define(‘MEDIA_TAGS_URL’, $mediatag_base);
Just change line 12 to be
define(‘MEDIA_TAGS_URL’, ‘galleries’);
I’ll do more testing on my end. But as I’ve mentioned to other commenters on this site. My test environment is pretty limited to my laptop and my server. It takes the user community to help with the environment variations. LEt me know if this does/doesn’t work. Be happy to help debug further. P-
August 24th, 2009 at 1:30 pm
i had no trouble locating that code and changing it, but no luck with the fix.
it also appears that the plugin isn’t looking at the mediatag.php template, because i made some changes to it and it’s still looking at archive.php (I did some back and forth testing to confirm).
i loaded a fresh 2.2 file just to make sure nothing i changed had done it.
sorry for all of these comments!
August 24th, 2009 at 1:33 pm
forgot to add – the testsite.com/galleries finds the mediatag.php template but no posts. the testsite.com/media-tags finds posts but not the mediatag.php template.
hopefully that helps for you narrowing down what’s going on.
August 24th, 2009 at 2:08 pm
@Ami: Hmm. Not really sure. I just tested this myself on my local laptop. Both options work as designed. I have a local WordPress version 2.8.4 with some Flag images used for chat icon. Loaded those and set the Media Tag to ‘Flags’ plus the country France, UK, USA, China, etc. Under Permalinks I have this set to ‘something/frank/galleries’. I’ve setup a new template file ‘mediatag.php’ in the WP default theme folder. which just echos the loop contents. No header or anything. Seems to display as expected. I have to ask this. Are you using Permalinks?
Not sure what to suggest. Would be glad to look at your site if you are willing to give me admin-level access. Email me off-list if you want with the login info.
August 24th, 2009 at 2:34 pm
hi paul! instead of me taking more of your time, let me play around with it for a little while more and see if i can get it working on my own. if it’s working for you it should be working for me!
am using permalinks. and i’m on 2.7.1 if that makes a difference?
if you wouldn’t mind emailing me with your email address that would be great, so sorry again for all of the questions!
August 24th, 2009 at 2:36 pm
@Ami: First email is paul@codehooligans.com
Second, I’ve not tested this all the way down to 2.7.1. I know the initial 2.0 release of the plugin worked but have not really tested all the latest features. There may be some expected issues since many of the items are fairly new in WP core.
August 24th, 2009 at 2:40 pm
OK maybe that is my issue then! It seems like everything is working except this template issue (which doesn’t *seem* like it would be version-related, but who knows?
And thank you for the email address! I will keep playing and keep you posted.
August 27th, 2009 at 4:56 am
Great work & amazing plugin! I just updated from the beta version, changed the renamed functions and it’s working perfectly. Thanks again for your work. Best
August 30th, 2009 at 9:14 am
[...] verspreche ich mir jetzt von dem Plugin Media Tags 2.0 vom Codehooligan Paul Menard aus Austin, Texas. Google half mir ihn zu finden. Das Prinzip ist ganz [...]
August 30th, 2009 at 10:21 am
@Ami: Hey wondering how you were coming with the Media Tags testing. Things sort of dropped off after we discussed a potential issue with you running WP 2.7. I’ve tested things on my end and everything seems to work correct in my local 2.7.1 instance. Including the Permalinks option.
August 31st, 2009 at 11:36 am
Paul,
Is there anyway to allow users to search only through media tags?
August 31st, 2009 at 11:44 am
@Carlos: If you are asking is there a way to intercept the front-facing search in WordPress. I’ve not figured out an acceptable solution for this. But I’m adding it to my list of future enhancements.
August 31st, 2009 at 1:10 pm
Paul,
That, or to insert a custom search form in the media-tags template page(s).
Thanks once again!
(I’m gonna poke around and see if I can find anything for this, but so far I havent had much luck).
August 31st, 2009 at 1:21 pm
to add..
there are obviously functions within WP that will allow this.
When you are in the admin screen, and viewing tags, you can search through them. So the work exists, it’s just a matter of creating a proper public interface for it.
August 31st, 2009 at 1:38 pm
Oh man.. I’m an idiot — I was able to do what I want.
Love WordPress and great work on the plugin, because..
When in a media tag page, say, /media-tags/beach/
I can just insert a search form on my custom mediatag.php template page, with the action on the form being the current URL of the page.
See, WordPress will search through tags via /tagname/tag/?s=search_query_here
..then it uses the same mediatags page to display them.
It works perfectly!
August 31st, 2009 at 2:22 pm
@Carlos: OH that is awesome news. Thanks for sharing. I’m sure others will appreciate this contribution. At the very least I appreciate the research on this.
August 31st, 2009 at 2:27 pm
[...] Media Tags 2.0 released Recent Comments [...]
September 4th, 2009 at 10:18 am
Hi,
First off, thanks for a great plugin.
I’ve got a strange issue, where I’m using the plugin as a means to tag images, then use that tagging to create some simple jQuery galleries.
To list the available tags I’m using the template get_attachments_by_media_tags(‘media_tags=homepage-gallery’); method. Which is working fine.
Once I’ve got that, I’m iterating over the result using a foreach loop. Within this loop I’m trying to use the getmediataglink() method, and passing in the id result from the for each loop, $v->ID etc. The getmediataglink() method seems to fail when I pass in a numerical ID. Using the wordpress template method wp_get_attachment_url($v->ID) works fine.
Am I missing something with the parameter that I should be passing into the getmediataglink() method?
Cheers.
September 4th, 2009 at 3:38 pm
@noponies: You are mixing up the template functions.
The function get_media_tag_link() is used to return a link for the media tag itself. In your case you have a collection (array) of images (actually post attachments) returned from the get_attachments_by_media_tags() call. To get the link you should use the WP function wp_get_attachment_url()
The get_media_tag_link() for example is used on the Library -> Media Tags listing. If you hover over a media tag item the quick menu show a ‘View’ link. This link was generated using the get_media_tag_link() call. Also if you display a list of media tags in your sidebar using the function list_mediatags() the media tags items are linked using the getmediataglink()
Hope this helps.
September 7th, 2009 at 3:13 am
Hi Paul,
Ahh, yep that makes sense. For some reason I assumed the get_media_tag_link() would return the link to the actual attachment item etc.
I did end up using the wp method wp_get_attachment_url().
Anyway, great plugin, really increases the flexibility of wordpress in regards to media elements etc.
September 7th, 2009 at 11:06 am
Hi,
I don’t get how to use it in my page.php file…
I tried :
$mediaTags = get_mediatags(‘media_tags=myTag&returntype=li’);
echo $mediaTags;
and I get “Array” in my page… i tried to manipulate it different ways but i failed. Even echo $mediaTags[0]; brakes my page.
Could someone please give me a code example… ? I try to use it with pdf so I need the title and the url. Thanks a lot.
Mik
September 8th, 2009 at 5:33 pm
[...] Media Tags plugin 2.2 for WordPress Release « CodeHooligans [...]
September 8th, 2009 at 9:36 pm
@Mik: Sorry for the delay. Was away for the long holiday weekend. Will need to check this. The call you are making the get_mediatags should work. Will need to test this on my own side. Will be back to you soon.
September 8th, 2009 at 9:47 pm
@Mik: Actually I just saw your issue. You have two problems with the function.
1. First you are calling the wrong template tag. You are calling ‘get_mediatags()’. This is a Taxonomy function similar to the template function get_categories() and get_tags(). I think what you want is to call get_attachments_by_media_tags()
2. You are using the wrong parameters in the call. Keep in mind you are calling the wrong function. In you parameters you are passing a wrong item. you are passing ‘returntype’. This should be ‘return_type’.
So if you call this function
$mediaTags = get_attachments_by_media_tags(‘media_tags=myTag&return_type=li’);
you should get an unordered list of items returned. Also keep in mind you will need to wrap your <ul></ul> around this output.
September 9th, 2009 at 3:35 am
Thanks Paul, it helped a lot ^^
It worked but the code wasn’t made to handle pdf files (What I was actually trying to do).
So I made this and it seems to work fine:
get_queried_object();
$postName = $post_obj->post_name;
//echo $postName;
$mediaTagsParams = ‘media_tags=’.$postName.’&media_types=pdf’;
$mediaTagsAtt = get_attachments_by_media_tags($mediaTagsParams);
if ($mediaTagsAtt) {
?>
ID);
$attLink = wp_get_attachment_url($Att->ID);
echo ‘‘.$attTitle.’‘;
}
?>
I use the page name to get pdf files with the same tag name to facilitate the insertion of pdf files to pages… so you just have to upload files and check the right tag to put it on the page ^^
Thanks for your great work!
September 9th, 2009 at 3:41 am
ok… my code wasn’t dispalyed well.
i replaced the arrows by brackets :
[?php
$post_obj = $wp_query-]get_queried_object();
$postName = $post_obj-]post_name;
//echo $postName;
$mediaTagsParams = ‘media_tags=’.$postName.’&media_types=pdf’;
$mediaTagsAtt = get_attachments_by_media_tags($mediaTagsParams);
if ($mediaTagsAtt) {
?]
[div class="mediaTagsAtt"]
[ul]
[?php
foreach ($mediaTagsAtt as $Att) {
$attTitle = get_the_title($Att-]ID);
$attLink = wp_get_attachment_url($Att-]ID);
echo ‘[li][a href="'.$attLink.'" class="lipdf"]‘.$attTitle.’[/a]‘;
}
?]
[/ul][/div]
[?php
}
?]
September 11th, 2009 at 12:23 pm
Hi, is it possible to specify size of pictures with shortcode? I want to show pictures with one media tag in page, but I want to show them as gallery, so it would be very helpfull to specify output (thumbnails with special css class with link to original picture). Thank you for your help… Anyway, great plugin, thank you very much…
September 14th, 2009 at 12:15 am
Great plugin! The backend is seamless, I’m just trying to make the backend display in my theme. It works great in the default theme; media-tags.php overrides just as designed, but it just calls up my post archive when I attempt to display a media tag archive. If I knew where/how the media-tags.php was inserted into archives.php I could probably fix it myself… it might be due to some other code work I’ve done on the theme. I’ll keep experimenting, but if you have an idea of how to do this, your input is invaluable. Cheers!
September 14th, 2009 at 8:50 am
Now I have it working–awesome! I thought the template file would be mediatags.php instead of mediatag.php for some reason. All sorted out–now to trick it!
September 14th, 2009 at 9:01 am
@Dan: Glad you figured it out. Was just about to respond. Yeah the template file is sigular, mediatag.php. You can change this if you edit the mediatags_config.php file where it is defined.
September 14th, 2009 at 5:09 pm
hi paul! so sorry for the delay in response – i was on vacation for two weeks. i’m upgrading my test site this weekend to see if the permalink fix works! thanks so much.
September 21st, 2009 at 6:10 pm
Is there a way to exclude tags from the cloud? I am making use of this plugin to highlight photos under specific categories, but don’t really want those categories to show in the tag cloud at large. Great plugin… redesigning a lot of my site around it.
September 22nd, 2009 at 8:14 am
@Dan: Thanks for the comment and kind words about the Media-Tags plugin. Look forward to hearing more about how you are using this plugin on your site.
As for your question yes there is a way to exclude items from he list. The Media Tags tag cloud function you are calling ‘mediatags_cloud()’ is a basic wrapper to the core WordPress tag cloud function ‘wp_tag_cloud()’. Part of the wrapper code is to set the Taxonomy so you are returned media tag instead of categories or post tags.
Looking at the WP Codex for the wp_tag_cloud function http://codex.wordpress.org/Template_Tags/wp_tag_cloud there is an ‘exclude’ parameter. This exclude parameter will be the ID of the media tag you want to exclude. Hope this works for you. If not let me know.
September 24th, 2009 at 8:26 am
Hey Paul,
I am unable to change the slug/url for established media-tags.
If I go to Media -> Media Tags -> Edit a tag (or Quick Edit), and try to change the slug, I get an error, “Tag not updated.”
Everything seems to work fine. Running 2.2.5
September 24th, 2009 at 8:36 am
@Carlos: You are running 2.2.5??? Man, my first and only suggestion at this point it to upgrade to the current 2.8.4. I did not plan to support anything older then 2.7.1
September 30th, 2009 at 9:37 am
Great plugin, but not compatible with WP Security Scan, which overwrites WP Version. Could change the function is_MEDIA_TAGS_URL() ?
September 30th, 2009 at 11:10 am
@dreb: Thanks for the comment. Not sure how the plugin is effected by the WP Security Scan you are referring to. And not sure what you are requesting. Do you want me to rename the function?
October 5th, 2009 at 3:20 pm
[...] verspreche ich mir jetzt von dem Plugin Media Tags 2.0 vom Codehooligan Paul Menard aus Austin, Texas. Google half mir ihn zu finden. Das Prinzip ist ganz [...]
October 7th, 2009 at 1:03 am
Hi, is it possible to use this plugin with WordPress MU? My idea: People wrote on their blogs for example about some film and upload pictures with the same media tag. And I want to show all pictures (from all MU blogs) with the same media tag. Thank you for your help…
October 7th, 2009 at 7:12 am
@Separatista: Good news is the Media-Tags plugin is compatible with WordPress MU. The bad news is what you are asking is not possible. In WordPress MU each site is contained in it’s own set of database tables. The Taxonomy queries uses via WordPress core are limited to only a given site. just like with categories and tags you cannot access Media-Tags across all sites within the same WordPress MU engine. Sorry, this is a limit in the WordPress MU core architecture not Media-Tags.
October 7th, 2009 at 11:51 am
Paul,
I meant that 2.2.5 was the version of the plugin I was using.
My WP version is the latest (2.8.4). Sorry about that.
October 10th, 2009 at 5:16 am
hello,
sorry for my silly question but i’m totally stuck. when i use the shortcode on a page : that works!
[media-tags media_tags="exemple?"]
when i call the function in a template : nothing happen…
$mediaTags = get_attachments_by_media_tags(‘media_tags=exemple’);
i really don’t understand…
any idea? thank you very much.
All the best from Paris, Emeric
October 10th, 2009 at 10:53 am
@Emeric: Thanks for the comment. Let me try to explain.
When I first wrote the Media-Tags plugin there was only the template function get_attachments_by_media_tags(); This function returns an array of attachments that match the query criteria. Sometime later I wrote the shortcode handler. When using the shortcode I don’t want to return an array because this will look bad on the output. So when using the shortcode the default return is an unordered list of items.
If you want the same output as the shortcode when calling the get_attachments_by_media_tags(); function then you need to call pass in another parameter like
$mediaTags = get_attachments_by_media_tags(’media_tags=exemple&return_type=li’);
then just echo the returned variable:
echo $mediaTags;
Another options- When you pass in the ‘return_type=li’ parameter the media tags code actually calls an internal function to handle the list item output. In the media tags plugin folder. Take a look at the file code for ‘mediatags_shortcode.php’. At the very bottom of this file is a function ‘default_item_callback’. If you want to have more control over the media-tags list item output you can define your own callback function in your theme’s functions.php file. Then pass that function name into the function call. For example let’s say you copied the ‘default_item_callback’ function into you own functions.php theme file and renamed the function ‘my_function’. you would then pass the name of that function in the the media_tags function like this
$mediaTags = get_attachments_by_media_tags(’media_tags=exemple&display_item_callback=my_function’);
Note when doing this you will need to provide the outer <ul> elements. This is muck like calling other WordPress functions like wp_list_pages(), wp_get_archives(), etc.
As always thanks for using the Media-Tags plugin and if you have any problems please met me know.
October 10th, 2009 at 1:25 pm
Hi
I wondered if it’s possible to control the size of the images that are displayed when calling media based on tags. Rather than display full size, I’d like it to show a ‘gallery’ of those items.
Is this possible – have I missed a trick somewheres?
Thanks – great plugin.
October 10th, 2009 at 3:53 pm
@Jonathan: Thanks for the comment. Via the Media Tags plugin it is not possible to control the size of the returned images. This is more a design decision on my part than a limitation in the plugin. By using the get_attachments_by_media_tags() function an array of images which match your query are returned. Via that array you can then pull in the thumb, medium, large of full size image yourself.
My reasoning for not allowing filter of the image size is that I didn’t want to take the next step where people will request something like an image manager that allows cropping and resizing of images on the fly. There are many great plugins out there that already provide this functionality. So I stopped at the management of the image Media Tags logic.
October 10th, 2009 at 5:25 pm
Online instructors need to set clear expectations and guidelines for course and discussion participation and use a variety of strategies to assess student learning. ,
October 11th, 2009 at 10:39 am
Thank you very much for the explanations! Very very helpful! Everything works now
I wanted to use media-tags to link posts and images. Exemple : show automatically in a post call “exemple” all the images tagged “exemple”. My idea was to call the slug (of media tags) the same as the ID of the post. CAD: All the images media-tagged 51 appear in the post 51. I wrote something like :
$mediaTags = get_attachments_by_media_tags(’media_tags=$the_id&return_type=li’);
but that didn’t work and my knowledge in php is limited
It could be amazing to have, in the next update, a new option in the post window : “choose your media-tags gallery” and automatically the images appear in the post
Anyway, thank you very much for your plugin. It’s already very helful. All the best from Paris, Emeric
October 12th, 2009 at 7:06 am
@Emeric: You are close on your logic. Instead of the Post ID you should match the Post slug to the media-tags slug. If you are using media-tags within the WP loop this should be something like:
$mediaTags = get_attachments_by_media_tags(’media_tags=’.$post->post_name.’&return_type=li’);
October 13th, 2009 at 10:28 am
Hello Paul!
First, I love this plugin. It is so useful! Thank you!
Currently, I am using it to display list of PDFs as an archive. Love it!
Here’s my problem: I want to use this plugin on a password protected site. If I login as a admin, I can see the list of PDFs. If I login as a subscriber, I just get a search box.
If I take off the password protection, everyone can see the list of PDFs just great.
At first, I thought it was the password protection plugin, so I tried another one. I got the same result.
I modified the media-tags URL and got the same result.
Do you have ANY suggestions? I would be so grateful if you could point me in the right direction.
Best,
Jaime
PS: http://wordpress.org/extend/plugins/members-only/
October 13th, 2009 at 10:47 am
@Jaime Chismar: Hmm that is an interesting issue. I’ll need to setup a test site on my end with that plugin to see if I can determine the issue. I’ve used the Force User Login plugin on client sites and works pretty much the same as the members-only. I’m not sure why WP does not allow subscribers to see the PDFs. Are you running any sort of Roles Management plugin that would override the default subscriber access?
Technically the media-tags plugin displayed attachments which are child items of the Pages/Posts in your system. Attachments don’t generally have their own access level. They will simply inherit access from the parent Page/Post. Meaning if the parent Page/Post is password protected for example then the attachment will have the same restriction.
I’ll investigate and email you if I find anything. Interesting concept.
October 13th, 2009 at 10:52 am
One final thought… Is there a way to get a media-tag category to display as an RSS feed. That may also solve the problem.
October 13th, 2009 at 10:57 am
@Jaime Chismar: Sure that is already built into the WordPress Taxonomy system. On your site you can access the media-tags archive something like:
http://yoursite.com/media-tags/
You just add ‘/feed’ to the end of it like:
http://yoursite.com/media-tags//feed/
I don’t think there is a way to do this via template code. Might need to add this in the next release.
Also, you can change this ‘/media-tags/’ part of the URL by going to your Settings -> Permalinks page. Down at the bottom you can enter whatever value you want to use.
October 13th, 2009 at 11:26 am
Hmmm… for some reason this doesn’t show up as an rss feed. I disabled the password protection to show you: http://clients.acg-analytics.com/media-tags/energy-environment/feed/
I am using the most recent version of WP. All of my other feeds from topics and categories are solid.
Thoughts? Did I miss a configuration in the Dashboard?
Best,
Jaime
October 13th, 2009 at 11:31 am
@Jaime Chismar: Strange. Not sure what is going on. Again, this is handled via WordPress core not the Media-Tags plugin. There is something in your rewrite rules preventing the feed from displaying? What other plugins are you running?
October 13th, 2009 at 11:42 am
Good questions:
1. I did not modify any core functionality, just templates.
2. I am only using three plugins: Yours : ), KB Advanced RSS Widget, and WP From Email. I deactived the password protection for now.
Do you have a URL for a working media-tags feed?
Again, thanks for checking into this. I really appreciate your help.
October 13th, 2009 at 11:44 am
@Jaime Chismar: Ok well geez what does the KB Advanced RSS Widget do? Can you disable the RSS widget to see if this solves getting the media-tags RSS. Also, since we have had so much back and forth any chance I can be granted access to your wp-admin? Email me via the contact form on this site if possible. Thanks.
October 22nd, 2009 at 10:26 am
My school system was almost entirely white and generally middle class. ,
October 23rd, 2009 at 6:03 am
Would be fantastic if the “Media Search” at …../wp-admin/upload.php would search throw these tags, too. Don’t know if it’s possible to improve this file – search in wordpress with the ability to search throw your media – tags, too?
October 23rd, 2009 at 6:21 am
After quick-editing a tag and try to save the new one:
Fatal error: Call to a member function using_permalinks() on a non-object in /(……)/wp-content/plugins/media-tags/mediatags_template_functions.php on line 80
October 23rd, 2009 at 7:39 am
THAT would be a good use of a big carbon tax. ,
November 2nd, 2009 at 11:43 am
Hello,
Just a little message to tell you since i have updated to 2.8.5 (i made some other changes but I guess it’s because of it), I can’t display listings of media tags like an archive.
http://www.yoursite.com/media-tags/ = Error 404 :-/
Anyway, thanks again for the plugin! It’s so useful!
All the best from Paris, Emeric
November 2nd, 2009 at 11:45 am
http://www.yoursite.com/media-tags/slug-of-my-tag (sorry!) = Error 404 :-/
All the best from Paris, Emeric
November 3rd, 2009 at 5:12 pm
@Emeric: Thanks for the comment. Will need to check the plugin in 2.8.5 Things don’t normally change with dot releases. But who knows. Sorry for the late reply. Have been out.
November 6th, 2009 at 11:13 am
hello, thanks for the great and useful plugin =)
I am trying to use compare_tags=AND to combine 2 categories. It works well when there are media in the both categories listed. But when there are no media in the both, or there is a media in only one category, I get a last media added (media in categories not listed too).
Can you help me please? I am taking a look in your code.
November 9th, 2009 at 2:29 pm
I was just wondering if you could explain to me what is actually supposed to go in get_attachments_by_media_tags(); parameters. I know that it is media_tags= but what does that even mean. Is it the post ID, the post name? The media-tag name? the media-tag ID? is there any documentation for this plugin?
November 9th, 2009 at 2:41 pm
@Alex Glover: The ‘media-tags’ parameter should be the Media Tag slug.
For example let’s assume you have media (images) tagged via Media Tags as ‘Tag1′, ‘Tag2′ and ‘Tag3′. The respective slugs for these tags would be ‘tag1′, ‘tag2′, ‘tag3′. OR more complicated a Media Tag ‘Vacation Texas’ would have a slug as ‘vacation-texas’.
Media Tags follow the same slug rules as Posts, Categories, Post Tags.
For documentation try reviewing the FAQ http://wordpress.org/extend/plugins/media-tags/faq/
November 9th, 2009 at 2:56 pm
Thanks for your speedy reply!!! I got that working, but is there something wrong with the parameters for post_parent?
$mediaTags = get_attachments_by_media_tags(‘media_tags=juicy-reel&return_type=li&post_parent=’ $child->ID); I even tried putting a number in the place of child->ID and it didn’t work. Any ideas?
November 9th, 2009 at 2:57 pm
Nevermind. I figured it out. Just letting you know that in your documentation in the readme.txt, it says post_parent and on your faq page it says postparent.
November 9th, 2009 at 3:08 pm
@Alex Glover: Thanks for letting me know that you figured this out. And for others who have the same question. The post_parent is the Post/Page ID not the media tag ID. Think about this. When you upload an image to WordPress it created an association between that item and the Post/Page. So by passing the post_parent you are limiting the search to only media items having that parent ID.
And Alex, yes I know the FAQ online is ‘postparent’ for some reason wordpress.org removes ‘_’ characters. Have not had time to look into the documentation to get around this. Thanks.
November 9th, 2009 at 3:12 pm
Actually I was wrong. I didn’t figure it out. It was apparently displaying ALL attachments that were tagged with that particular tag. Any ideas? Sorry about the storm of posts!
November 9th, 2009 at 3:27 pm
@Alex Glover: Alex not know your system or what post/page you are using it’s difficult to provide guidance. Sorry.
November 11th, 2009 at 11:37 am
Hi,
Thanks for the plugin, its made my day. It should be core, its so flexible, thanks alot.
One question, is there a parameter for get_attachments_by_media_tags that allows for negatives, or to get images that are not tagged.
At the moment I am using the two tags (finishes,techincal) to display two images in different places. There is also a slideshow on the page, which also displays images tagged product.
Ideally I would like to query for images that are not tagged either finish or technical.
Currently every image in the slideshow has to be tagged, which a little time consuming.
Thanks again,
Ian.
November 11th, 2009 at 11:45 am
@Ian Atkins: Ian that is actually a really nice suggestion. And the first one I’ve had to provide a ‘not’ tagged. Will need to figure out the mechanics of this. Currently as far as I can tell this is not something supported by the WordPress Taxonomy system. Since version 2.0 the Media Tags plugin has used the Taxonomy system for storing tag information to post relationships. This is the same system used for example when you set the category or tag for a post. To my knowledge there is not a way to select the ‘not’ tagged items. But let me work on that. And again great suggestions.
November 11th, 2009 at 3:06 pm
Hi Paul.
I was thinking of coding it by taking a get_posts query and then comparing the id’s of the results against the media tag query. But I thought that might of been a rather long winded way of doing things.
I’m not too hot on array’s, but I’ll let you know if I have a stab at it.
Thanks.
November 16th, 2009 at 4:36 pm
Hey Paul,
Great plugin. It’s letting me do some cool stuff in tandem with the jQuery Cycle plugin.
One question: it’s not clear to me how I’d grab the captions, etc. associated with an image. Is this possible with one of the existing functions, or even with some custom code?
November 16th, 2009 at 5:33 pm
@Ryan: There current aren’t any hook to all for display retrieval of the caption information via the Media Tags plugin. That is a great idea though. I’ll need to see about including that in the upcoming release.
November 17th, 2009 at 4:25 pm
Hi Paul,
in next release, could you replace the string “wp_posts” by “$wpdb->posts” in the function mediatags_postsWhere (see mediatags_rewrite.php). Otherwise, your great plugin does not work when the database prefix is changed from “wp_” to anything else.
November 17th, 2009 at 5:38 pm
@dreb: Yes, definitely! Sorry for missing that. I stole that code from another plugin and didn’t catch the hard-coded table reference.
November 17th, 2009 at 6:41 pm
Thanks for the quick response Paul. I did some searching and it doesn’t seem easy to do this manually; I’m not sure what WordPress functions you’d use to grab that info, but you could be the first person to figure it out!
November 17th, 2009 at 6:52 pm
@Ryan: I’m up for that challenge. So question on how you are using the Media Tags plugin. There are two basic way. View the template code or via the shortcode?
November 18th, 2009 at 10:58 am
Nice
I’m calling the function in the template.
November 22nd, 2009 at 11:14 pm
@Paul: “By using the get_attachments_by_media_tags() function an array of images which match your query are returned. Via that array you can then pull in the thumb, medium, large of full size image yourself.”
Could you elaborate on this or point me in the right direction?
Your media_tags plugin seems to be almost exactly what I need, but I’m stuck. I intend to setup a couple gallery pages that will pull images posted with WP’s built-in media handler. With your plugin, I’ve tagged the images I want pulled into this page “paintings”. Using shortcode on the page [media-tags media_tags="paintings"] pulls in the images I’ve tagged “paintings” successfully, but it’s pulling in the full sized ones. I would like to pull in thumbnails instead and have each of those link to the full-size image. That’s all I want to do (no fancy dynamic resizing, captioning, etc). In your response to a previous question, you allude to this being possible by utilizing the array of images generated by the get_attachments_by_media_tags() function. I’ve searched all over and can’t figure this out. I tried a few gallery-specific plugins, but each one would essentially force me to start over with all of my images that already exist in WP’s media library and in my blog posts. Also, their functionality seems like overkill when all I need is a simple list of images that dynamically grows as I upload new images and tag them with your clean plugin. Thanks for your time!
November 30th, 2009 at 7:50 am
Like Alex, I’m have trouble with post_parent. Despite setting the post_parent=this, it still pulls in all images site wide with the header tag.
I’ve tried variations such as =’this’, =\’this\’ etc. and no luck. Only specifying the exact id will it limit it (but I want to keep that id dynamic)
November 30th, 2009 at 7:51 am
$mediaTags = get_attachments_by_media_tags(‘media_tags=header&post_parent=this&return_type=li’); echo $mediaTags;
Try it without the php bits at the start and end this time!
Cheers
November 30th, 2009 at 7:57 am
I did get it working by doing this, but I’m sure that’s going about it the long way and there’s a trick to getting post_parent=this to work
$current = $post->ID;
$mediaTags = get_attachments_by_media_tags(‘media_tags=header&post_parent=’.$current.’&return_type=li’); echo $mediaTags;
December 4th, 2009 at 6:42 pm
Sorry, my last post had a typo in the second URL
http://oregon.cyclingaction.com/images/ryan-trebon/
December 8th, 2009 at 4:09 am
For reference, since I couldn’t find this written anywhere, these are the fields for each item in the array returned by get_attachments_by_media_tags():
ID
post_author (id)
post_date (like 2009-12-02 16:08:08)
post_date_gmt
post_content
post_title
post_excerpt
post_status
comment_status
ping_status
post_password
post_name
to_ping
pinged
post_modified
post_modified_gmt
post_content_filtered
post_parent
guid (contains url to full-size image)
post_type (always “attachment”)
post_mime_type
comment_count
If you are using the full sized image, “guid” from this array will give you the URL. If not, you can pass the id to wp_get_attachment_image_src($ID, ‘size_name’), where size can be “thumbnail”, “medium”, “large”, or “full”. This returns an array, of which spot 0 gives the URL, 1 gives the width, and 2 gives the height.
December 8th, 2009 at 8:20 pm
Hey Paul,
Just an FYI, when I go to Media > Media Tags and do a quick edit, the following error pops up:
get_attachments_by_media_tags()
December 8th, 2009 at 8:20 pm
I mean…the following error pops up…
Fatal error: Call to a member function using_permalinks() on a non-object in /homepages/26/d292238976/htdocs/wsb5417974701/wordpress/wp-content/plugins/media-tags/mediatags_template_functions.php on line 80
December 8th, 2009 at 8:55 pm
Paul,
Last comment — just wanted you to know I figured out my last problem. The docs are unclear on how to use the template function; you need to specify the return_type parameter as li or you won’t get anything.
Thanks for your hard work and a great plugin.
December 12th, 2009 at 8:12 am
[...] la fonction native de bibliothèque Média de WordPress est pratique, surtout avec l’extension Media Tags; [...]
December 15th, 2009 at 7:42 am
Will this plugin work if attachments are added when creating posts from “QuickPress” on the dashboard or using a desktop app like MarsEdit?
December 16th, 2009 at 11:41 am
@Daniel: I’m not familiar with the way these third-party application function in regard to adding attachments for a Post/Page. I’m assuming these application function just as if you are adding the attachments via the web wp-admin interface.
December 31st, 2009 at 11:56 am
Is there a way to test if a given image has a media tag? I have a function that returns an array of images, and I want to iterate over that array and see if there are media tags associated with the image. If there’s not already a function for this, can you tell me where the tag information for the image is stored in the database, and I’ll add that to the sql statement? Thanks!
December 31st, 2009 at 12:27 pm
@Kim Flournoy: Actually no need to resort to your own custom SQL. As of 2.0 the Media Tags plugin uses the WP Taxonomy system. This is the same system used by post categories and tag.
So to check if a given image has media tags you should simply need to call
get_the_terms( $id = 0, $taxonomy )
The id is the post id of the image. The taxonomy is the media-tags taxonomy which is ‘media-tags’ or use the define MEDIA_TAGS_TAXONOMY which is set in mediatag_config.php
Give that a try and let me know.
December 31st, 2009 at 3:08 pm
Yup, that was the missing piece of the puzzle. Thanks so much – Happy New Year!
-Kim
January 7th, 2010 at 6:50 am
Hi Paul
I am very keen to use media tags as it is just what I need.
But installation leads to a number of php errors in my worpress installation – which is 2.9.
These include: Undefined index: activate in media_tags.php on line 76
Notice: Undefined property: WP_Query::$is_mediatags in mediatags_rewrite.php on line 60
Notice: Undefined variable: whichmediatags in /mediatags_rewrite.php on line 145
Undefined variable: update_message in mediatags_admin.php on line 837
I don’t think this is a plugin conflict as mediatags was the first plugin I installed.
Are the errors because I am using worpress 2.9?
Or do you have a rough idea of where the problems might be coming from?
January 7th, 2010 at 6:53 am
I should have said – despite the errors – Media Tags does seem to be more or less working.
January 7th, 2010 at 8:05 am
@Frances Leyland: Thanks for the comment. Yeah I do have some work to do for the 2.9.x updates. Seems the WP core has more changes. Look for an update soon.
January 7th, 2010 at 5:28 pm
Thanks. Though if you turn off debug, there is no problem. Just looks a bit messy at the moment.
January 12th, 2010 at 10:35 am
Awesome plugin, easy to use, no issues following instructions… but I want to cast my vote for including a tag cloud function… or… do you know of any other tag cloud plugin that can pick up on your plugin’s tags?
January 12th, 2010 at 11:48 am
@Casey: Thanks for the note. And Thanks or the vote. The good news is the Media Tags plugin already supports a Tag Cloud feature. mediatags_cloud(). This function is a clone of the default WP Tag Cloud function http://codex.wordpress.org/Template_Tags/wp_tag_cloud
January 15th, 2010 at 5:07 am
Good work Paul, this plugin is perfect for my job, but it lacks of documentation, don’t you think?
Where are public usage guidelines?
I’m lost reading all this comments!!.
I hope it’ll come soon!
January 15th, 2010 at 9:11 am
@Enrico: Thanks for the comment. The ‘public usage guidelines’? Not sure I follow your question. If you have some specific need just ask. I’ll try and point you to the correct usage.
January 15th, 2010 at 9:41 am
Thanks Paul, I’m happy to tell you that I found instruction in readme.txt inside of the plugin package!
.
Usually I find usage guidelines directly in the official plugin’s web page, so here is my question
I’m also glad to let you know that I’ve developed a widget plugin for your awesome new version of Media Tags, because I need it for my job.
If you want i can share my code with you, maybe it could be included in a next release.
Let me know, email me if you want.
Thanks.
January 15th, 2010 at 9:43 am
@Enrico: Nice. Yes, would love it if you shared you Widget code. I’ve also been working in a Widget for the next release but have been behind on some client work (my day job) so have not had much time to finish things. Feel free to email the code to me paul {at} codehooligans {dot} com
January 19th, 2010 at 12:58 pm
I must say that this plugin was exactly what I was looking for. Thanks for the great work.
January 31st, 2010 at 4:39 am
Hi Paul! And again, thanks for your great work.
I’m going crazy trying to automatise the function of the plugin so it can automatically show all the attachments with a certain tag in the page which slug is the same (as the tag). I’ve figured out this code but it doesn’t work…
2
3
4
5
6
7
8
'media_tags' =] the_slug,
'orderby' =] 'date',
'order' =] 'DESC',
'numberposts' =] '6',
'return_type' =] 'li' ); ?]
[?php $mediaTags = get_attachments_by_media_tags($tagArgs); echo $mediaTags; ?]
May someone have already posted the solution, but I have not been able to find it… Anyway, thanks in advance.
January 31st, 2010 at 10:49 am
@Carlos R: Thanks for the comment. Depending on your hosting environment you might be seeing an error. Or if this is a typical live environment you may not since you host will probably disable PHP errors. The only error/issue I see is that the media_tags parameter in your array needs to be enclosed in quotes like all the other values. Let me know if this helps. Thanks.
January 31st, 2010 at 5:01 pm
Thanks for the swift answer, but the_slug is a custom function to pass the page slug as the media tag, so adding quotes will not help me, because the plugin would search for “the_slug” tagged media…
January 31st, 2010 at 8:15 pm
@Carlos R: Guess I’m a little confused as to why you are passing a callback function reference into the media_tags field of the array. First and foremost you cannot pass a bare variable into the array construct. You WILL cause an error. Per the documentation for the Media-Tags plugin (I know they need work) the ‘media_tags’ parameter is to be used for the search media tag. The only function reference allowed is the ‘display_item_callback’ function. If this is defined then the media tags plugin will call it to display the media tag element.
February 1st, 2010 at 5:15 am
Ok, so this is not the way, I guess
What I want is to pass the page slug automatically to the get_attachments_by_mediatags function, so, for example:
You’re in a page called “Recipes”, which has the slug “recipes”. So I want to show all the media tagged “recipes” to appear automatically, without the need to hardcode the tag each time I create a new page.
This way, I can have a way to automatise this throught the template. Is this doable?
Thanks for your interest!
February 1st, 2010 at 8:41 am
@Carlos R: This is totally doable. On a page or the single.php template within the look you have access to the WP post variable post -> post_name. The ‘post_name is the Page/Post slug. So you just need to pass that into the ‘media_tags’ array parameter.
February 1st, 2010 at 9:25 am
My real problem is that I don’t know PHP
Could you please tell me how to pass the variable into the array?
I also have the code outside the loop, so should I open a new query?
Thanks again!
February 2nd, 2010 at 5:26 am
Ok, I got it! It goes like this:
2
3
4
5
6
7
8
9
'media_tags' =] $post->post_name,
'orderby' =] 'date',
'order' =] 'DESC',
'numberposts' =] '6',
'return_type' =] 'li'
'size' =] 'thumb' ); ?]
[?php $mediaTags = get_attachments_by_media_tags($tagArgs); echo $mediaTags; ?]
But now I can’t get the “size” parameter to work. How can I get a list of thumbnails instead of full images? Thanks in advance.
February 2nd, 2010 at 7:36 am
In addition to the previous, what should I do to link the gallery thumbnails to the images?
February 14th, 2010 at 11:57 pm
Paul, great plugin. I’m using it in xmlrpc to pass data into Flash for cms purposes.
One question : I’m confused as to why this method does not pass back a param that is tag name? This seems like an essential piece. Is there another way to get this?
February 22nd, 2010 at 10:47 am
Hi Paul,
I’m attempting to create an intranet site and wanted to have a page of PDF links using your plugin so users could just tag their media uploads and have them appear on the proper page. I’m attempting to use the shortcode to inject the PDF’s into the page; but all I see are the appropriate number of bullets with no link to the PDF. I’m using WP 2.9.2, is there some example code somewhere? Shouldn’t [media-tags media_tags="downloads"] just display all the PDF’s with the ‘downloads’ tag or is it necessary to modify one of the template files to use the shortcode?
February 23rd, 2010 at 9:28 am
Around line 83 of media_tags.php looks like this:
if ((isset($_REQUEST['activate'])) || ($_REQUEST['activate'] == true))
{
$this->mediatags_activate_plugin();
}
This does not look like it is logically correct (and kicks up a warning ‘Undefined index: activate’). Should a logical AND ?
February 25th, 2010 at 3:50 pm
I built a custom function that would query the database for all existing mediatags and list attachments for each mediatag underneath. It also filters out the attachments to only display those that were uploaded by the currently logged in user. This is something we needed to build for a client looking to setup a file management type system. The code isn’t pretty and displays all mediatags whether the currently logged in user has attachments in them or not:
function list_attachments_by_user_tags() {
global $wpdb, $current_user;
$user_id = $current_user->ID;
$catQuery = $wpdb->get_results(”
SELECT *
FROM $wpdb->terms AS wterms INNER JOIN $wpdb->term_taxonomy AS wtaxonomy ON ( wterms.term_id = wtaxonomy.term_id )
WHERE wtaxonomy.taxonomy = ‘media-tags’
AND wtaxonomy.parent = 0
AND wtaxonomy.count > 0″);
foreach ($catQuery as $category) {
echo ” . $category->name . ”;
$media_items = get_attachments_by_media_tags(‘media_tags=’.$category->slug);
if ($media_items) {
echo ”;
foreach ($media_items as $media_item) {
if ($media_item->post_author == $user_id) {
echo ”;
echo ‘ID) . ‘”>’ . $media_item->post_title .’‘;
echo ”;
}
}
echo ”;
}
}
}
I’d love to hear some feedback.
February 25th, 2010 at 3:53 pm
My last comment removed all the html from my function, so it probably looks broken. Hopefully this works:
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
global $wpdb, $current_user;
$user_id = $current_user->ID;
$catQuery = $wpdb->get_results("
SELECT *
FROM $wpdb->terms AS wterms INNER JOIN $wpdb->term_taxonomy AS wtaxonomy ON ( wterms.term_id = wtaxonomy.term_id )
WHERE wtaxonomy.taxonomy = 'media-tags'
AND wtaxonomy.parent = 0
AND wtaxonomy.count > 0");
foreach ($catQuery as $category) {
echo '<li><h3>' . $category->name . '</h3>';
$media_items = get_attachments_by_media_tags('media_tags='.$category->slug);
if ($media_items) {
echo '<ul>';
foreach ($media_items as $media_item) {
if ($media_item->post_author == $user_id) {
echo '<li>';
echo '<a href="' . wp_get_attachment_url($media_item->ID) . '">' . $media_item->post_title .'</a>';
echo '</li>';
}
}
echo '</ul>';
}
}
}
February 27th, 2010 at 7:26 am
Hi Paul,
Is there anyway to exclude a particular media tag from the list returned by get_attachments_by_media_tags. I’ve tried the usual wordpress ‘exclude’ and ‘tag__not_in’ etc, but come up short. I can get around is using array methods on the returned list, but a simple exclude command would be handy.
March 4th, 2010 at 8:52 pm
Three suicide attacks in the central Iraqi city of Baquba kill at least 31 people, days ahead of parliamentary elections.
March 19th, 2010 at 3:19 pm
Hi paul, I was wondering if I can use 2 calls of get_attachments_by_media_tags in a same page, because i’m trying to do this, but on second call.. always return empty result..
I take a look to your code and found the problem, but i cant fixit… on second call, media_tags.php file, at this line:
$attachment_posts = get_posts($query_str);
get_posts return nothing…. the strange thing is that on my localhost (LAMP) works fine, but on hostgator fails.. any help?
March 20th, 2010 at 6:25 am
@Pachi: Thanks for the comment. Having multiple calls to MEdia Tags (assuming you are using shortcode) should work just fine. Can you provide the exact call parameters you are using for both? I would like to review and test on my dev system. Thanks.
March 25th, 2010 at 1:11 am
I’m working with a beta of wp3.0 and tried installing MediaTags and it crashed. Seems that $wp_rewrite is null when you attempt to register taxonomy on line 67 of media_tags.php which is in the MediaTags class instance constructor. The error message started with:
Fatal error: Call to a member function add_rewrite_tag() on a non-object in /Users/myname/Sites/mysite/wp-includes/taxonomy.php on line 268
I found that by initializing the MediaTags class instance it in an ‘init’ hook rather than simply at the bottom media_tags.php seems to have solved the problem (though I haven’t fully tested it yet.)
So instead of what is on line 410 of media_tags.php:
$mediatags = new MediaTags();
?>
Use this:
add_action(‘init’,'init_media_tags’);
function init_media_tags() {
$mediatags = new MediaTags();
}
?>
HTH.
-Mike
March 25th, 2010 at 1:41 am
Oops, I think I spoke too soon. Maybe it should look more like this (note the “global” declaration):
add_action(‘init’,’init_media_tags’);
function init_media_tags() {
global $mediatags;
$mediatags = new MediaTags();
}
?>
March 25th, 2010 at 6:13 am
@Mike Schinkel: Thanks for the notes on this. I’ve not had a chance to do a 3.0 review. Will apply these changes you suggested.
March 25th, 2010 at 10:51 am
just wanted to thank you for making this extremly helpful plugin – I was for a way to let use images in custom places in my templates but in a more user-friendly way thank coping urls to custom fields – this plugins works perfectly for this task
March 27th, 2010 at 10:13 am
Paul, I cannot thank you enough for this plugin. I have a lot of PDFs on one of my sites, and media-Tags makes the organization easier, and the presentation better.
One slight frustration I had was the necessity to edit tables directly to make proper use of sorting by menu_order – I cannot find an edit screen in WordPress that allows me to change this for anything but Pages.
Anyway, I hacked your code in mediatags_admin.php and added the following to the beginning of mediatags_show_fields_to_edit
$form_fields['menu-order'] = array(
‘label’ => __(‘Menu order:’),
‘input’ => ‘html’,
‘html’ => “ID][menu_order]‘
id=’attachments[$post->ID][menu_order]‘
size=’10′ value=$post->menu_order />”
);
It works brilliantly – I can now order my lists easily at the same time as adding the media tags. Thanks again – I’ll go and give you the 5 stars in WordPress.org you so richly deserve.
March 27th, 2010 at 7:49 pm
@Keith from shrewdies: Thanks for the comment. And thanks for the code addition. I’ll review and consider adding in the in the soon to be released next version. And thanks for the 5 stars. Much appreciated.
March 28th, 2010 at 12:24 am
@Paul: Thanks for the reply.
Another note on Media Tags, I’m following Andrew Nacin’s recommendation[1] to use WP_DEBUG and I’m getting lots of undeclared variable errors (which are easy to fix, but if I fixed, you revise and then I upgrade, my fixes are gone.) I’m wondering if when you do your 3.0 review you can do it with WP_DEBUG turned on?
Thanks in advance.
[1] http://www.andrewnacin.com/2010/03/22/deprecated-functions-and-wp_debug/
March 29th, 2010 at 7:42 pm
Aloha Paul, I just wanted to thank you for your hard work on Media Tags. I’ve just created a short-code plugin that uses your plugin to get images into a gallery. Tag Gallery is just like the gallery short-code already included with WordPress but uses tags from your plugin to get the images. Your tags and my plugin make it much easier to manage galleries rather than the currently awkward way it is done. Anyhow, thanks again and if your interested, check out the plugin on WordPress at the following url http://wordpress.org/extend/plugins/tag-gallery/
Once again, thanks and aloha.
March 29th, 2010 at 8:43 pm
@Johnny Peck: Thanks for the reply. I just checked out your plugin. This is freakin awesome! Thanks man. One note or request. In the description page can you add a link to the Media Tags plugin in the line “REQUIREMENTS: You must have Paul Menard’s Media Tags plugin installed or it will do nothing for you.” would make it easier for people to download. Thank again.
March 30th, 2010 at 12:36 am
Paul, I just updated the description with a link. It should update to the plugin’s site next time they update. I guess 15 minutes or so. I’m glad you like it!
March 30th, 2010 at 9:11 pm
??? ??????????, ?? ?????? ????.
March 31st, 2010 at 6:32 am
Hi Paul, I used your plugin on a charity website that needed a list of newsletters in the sidebar. So I create a widget to handle this. I decided to release the plugin so it is available to others until you have a chance to implement widgets on your plugin. The plugin is named “Media Widget”.
Thanks for your plugin – it is very useful.
March 31st, 2010 at 7:27 am
@Bev: This is awesome. Thank you so much for sharing this great work. You and others have really taken the time to put together some great tool using my Media Tags plugin as a base. Thank You. Thank You. thank You. I’ve just not had the time to work on a widget. No I see there is really no need. One note if I could make a suggestion. In your plugin description “…list media tagged using the Media-Tags plugin by Paul Menard.” Would it be possible for you to link to the Media Tags plugin page http://wordpress.org/extend/plugins/media-tags/. There are a few copy cats out there doing similar Media tagging projects and would not want someone downloading your plugin to use the wrong media tagging plugin. Thanks again and thanks for sharing.
March 31st, 2010 at 9:27 am
Hi Paul, I added the link.
My plugin also checks for the presence of yours and shows an error message with a link if it is missing.
Cheers!
April 1st, 2010 at 8:11 am
??????????? ??? ???????, ???????.
April 6th, 2010 at 9:58 am
Great plugin! This has saved me lots of time. One minor thing: different sources document the name of the archive template file differently. The body of this post says it’s mediatags.php, as does the readme.txt included with the plugin, but the writeup on the WordPress Plugins Directory and your comments here indicate that it’s mediatag.php. I did figure out that it’s the latter, but it took a bit of messing around to discover that this was my issue. Thanks again for your work on this!
April 6th, 2010 at 6:52 pm
I have an issue with the plugin: Media tags appear in my post-tagcloud. I’ve now created four media tags, and two of them are also in my posts tag cloud, two of them are not. All tags have associated media.
Is this a known issue?
April 6th, 2010 at 7:20 pm
@Diana: This is strange and for the record not a known issue. The Media Tags are stored in their own Taxonomy in WordPress. So to say they are showing up in your post tag cloud seems strange. Is there a page I can see this on? Also what version of WordPress? What other plugins are you running?
April 7th, 2010 at 2:53 pm
Hello Paul,
i figured out what the problem was, but not how it was caused: Two of the media tags were copied to the post tags, for some reason. I’ve already cleaned it up. I’m running the latest version of WordPress with the following plugins:
- Admin Notes
- Autotagger
- Media Tags
- Tag Gallery (not used in any posts yet)
I feel that Autotagger may have something to do with it, the two media tags that were copied did have a post tag as substring. I’ve tried to reproduce the error, but couldn’t. If I find a way to reproduce it, I’ll let you know.
April 8th, 2010 at 7:59 am
I have a problem use your plugin on my site but some essentially things do not work.
When i am trying to use the permalinks and go to the address something/media-tags/sometag I only get a 404 back. Every time. Second thing is: Shortcodes doesn`t work either.
I managed to hardcode php-code into template-files, and got some tagged files back, but I would appreciate to use the template without hardcoding (especially because I am just the admin, not the user adding those tags)
My site is only for registered users accessible and for this reason it is heavily using plugins, but as far as I can tell by looking into your code (or hooks), those aren’t interfering. (I also gave it a try with all critical 3rd-party plugins disabled, but doesn`t work).
Any similiar errors known? Maybe something with my server configuration?
Beste regards, bas_der_gruene
April 8th, 2010 at 11:35 am
@bas_der_gruene: Well how about some information regarding your setup. Since you provided an example of the media-tag URL. I’m assuming you have Permalinks enabled. Can you provided what version of WordPress you are running? What other plugins you are running? Etc. Also, since the shortcode is not working can you ensure the Media Tags plugin is actually enabled. Thanks. Let me know. Best.
April 8th, 2010 at 3:59 pm
Media Tags plugin works almost fine. I can use those template-functions, my Media is already tagged. I do run the newest wordspress version 2.9.2
Those Plugins are running (and may be important) on my site: Advanced Category Excluder, Event Calendar, Recent Comments Widget, Brien`s Threaded Comments, Role Manager, User Access Manager (+some smaller, some own ones)
I think I have to find this bug myself, especially because I first have to do a research which changes I made to my theme over the last two years. Some of them aren`t standard procedure, I think…
Just wanted to know wether there are any similar bugs known.
Hav a nice Day, and thanks for the plugin, bas_der_gruene
April 9th, 2010 at 8:50 am
Great plugin – much needed functionality!
However, I can’t seem to find a way to, from the Admin end, easily filter by Tags. Yes, if I click on a tag in the Media Tags column, it filters by that, but this requires me to first find a media piece with the tag I want to filter by – which kind of defeats the purpose.
What about a list of all Media Tag Cloud available on that page to assist in filtering? (maybe hidden until someone clicks ‘Show tags’?)
thanks again for the plugin!
– jason
April 9th, 2010 at 11:38 am
RE: my last post
Ok, found I can click Media Tags, then click the # in the Used Column to filter by that! Yay!
– jason
April 21st, 2010 at 8:54 am
Hi – having some trouble with the /media-tags/slug view, in that it keeps saying nothing matched my post.
I’ve double checked the permalink structure, but like I said, I get “No posts matched your criteria” rather than a 404.
I know that I have media tagged with those things.
I get the same thing when I click on the View link from the Media Tags when a tag eveb says it has 2 things.
Can you confirm this page works in a MultiUser environment? I don’t see why this one part of it wouldn’t. I’m running 2.9.1.
Also, is it possible to use TWO slugs like this? Such as:
/media-tags/foo/bar or foo+bar?
Please let me know if you have any suggestions!
Thanks!!
April 21st, 2010 at 10:58 am
@MadtownLems: I can confirm the Media Tags plugin should work on WPMU. Though I’ve not tested on 2.9.1. More like 2.7.1. Some version from last summer. Do you have a public URL for me to investigate the issue?
And no the plugin was not developed with the ability to concat tags together. This may be coming in a future release.
April 22nd, 2010 at 8:35 am
@James Braithwaite: James, My apologies. This is an actual bug in the code. Seems some code I lifted from another plugin way back in 1.0 has some hard-coded table prefixes. If you want to make the edit open the file mediatag_rewrite.php. In this file is a function ‘mediatags_postsWhere’. Within that function there are 7 instances where ‘wp_posts’ was used. These need to be replaced with ‘$wpdb->posts’. I have this fixed and working on some other changes before submitting the plugin to the wordpress.org repository.
April 25th, 2010 at 3:28 am
This is a great plugin… would it be much trouble to extend it to Links as well? Ideally, a tag page would call up all posts, pages, media files and links that have that tag slug.
It seems like the WP core development team for 3.0.x (sometime this year) wants media and users to have both categories and tags (I hope they are considering links too), so that everything can be tagged or categorized.
You should get your work into the core.
If you don’t want to work on Link tags, I wouldn’t mind trying my hand at modifying your code to do it.
April 25th, 2010 at 11:02 am
@spacechampion: That is an interesting concept on the Link tagging. I would not modify the Media Tags plugin. Instead maybe clone some of the code and use it as a new plugin. And yeah I read about WP core team identifying features like Media tagging to be included in core. The have done this to me before. Two years ago I wrote a Revisions plugin to handle Post and Page versioning and restore. Six months after they included versioning in WP core. I do know that have looked at my Media Tags code for considerations. Which does make me somewhat happy.
Back to the Link Tagging I don’t think it will take much. Thanks for the idea. I’ll start on that soon.
April 26th, 2010 at 2:19 pm
hi. i seem to be having some issues with getting good ol 404s when i click on a media tag link. i’ve successfully assigned tags and gotten them to show up in the sidebar widget, but when i click the link, it doesn’t find anything. at first i thought this might be because i was linking to images that only existed inside a gallery, but then i tried it for an individual post with only one (tagged) image placed in it–still no luck.
i’m running an independently hosted wordpress 2.9.2 blog with the following plugins: akismet, google xml sitemaps, lightbox 2, media tags, seemore, sliding read more, and tag list widget. any opinions? thanks!
May 7th, 2010 at 12:24 pm
Hi again Paul, Just a heads up about another plugin of mine that makes use of your Media Tags. WP-Imageflow2 will generate a CoverFlow style image gallery of tagged images.
May 19th, 2010 at 7:48 am
@Paul: Thanks for the reply.
Another note on Media Tags, I’m following Andrew Nacin’s recommendation[1] to use WP_DEBUG and I’m getting lots of undeclared variable errors (which are easy to fix, but if I fixed, you revise and then I upgrade, my fixes are gone.) I’m wondering if when you do your 3.0 review you can do it with WP_DEBUG turned on?
Thanks in advance.
[1] http://www.andrewnacin.com/2010/03/22/deprecated-functions-and-wp_debug/
May 22nd, 2010 at 12:35 pm
Hi Paul,
as @bas_der_gruene I can’t use permalinks to show archived media llink mysite.com/media-tags/sometag I get a 404 error page.
Any news?
Thanks in advance.
May 24th, 2010 at 11:46 pm
I’m having the same issue with 404′s on the media tag archives. No amount of setting up templates seems to alleviate. As near as I can tell something is broken with wp-rewrite, though I’m not sure what.
May 25th, 2010 at 8:59 am
@Finster:
I’ve finally had a chance to research this. I made some dumb changes to the init of the plugin based on some suggestions from others. It is this init hook where the rewrite logic is setup for the media-tags templates. I’ve just updated the plugin version 2.2.8 into the wordpress.org repository. Should fixe the issues. Apologies to all effected by this.
May 29th, 2010 at 5:31 am
Perfect! It works like a charm?
Is there a way to know in which tag we are, when visiting a particular archive page?
I’m just trying to build a “by tags”-navigation menù, but no way (for now) to highlight selected tag when I am in archive template.
I like to have a solution like “current-item” css-class in WordPress navigation links.
Any idea?
Thanks for your work!
May 30th, 2010 at 1:22 pm
not working with latest 3.0 RC:
Fatal error: Call to a member function add_rewrite_tag() on a non-object in /var/www/vhosts/seo-konzultant.cz/httpdocs/wp-includes/taxonomy.php on line 282
May 30th, 2010 at 5:43 pm
@noname:
I’m still waiting on the WP 3.0 Beta series to finalize development before submitted another patch for the Media-Tags plugin. In order to get this working edit the main plugin file ‘media_tags.php’ Look about line 67. You should see ‘$this->register_taxonomy();’. Move this complete command into the function init(); at line 79. The complete function init(); should look like this:
function init() {
$this->register_taxonomy();
mediatags_init_rewrite();
// Checks ths plugin version again the legacy data
if ((isset($_REQUEST['activate'])) && ($_REQUEST['activate'] == true))
{
$this->mediatags_activate_plugin();
}
}
May 31st, 2010 at 9:53 pm
Fatal error: Call to a member function add_rewrite_tag() on a non-object in /home1/dotnatur/public_html/blogtremblant/wp-includes/taxonomy.php on line 275
with latest wordpress
June 1st, 2010 at 6:32 am
@does: See this comment
http://www.codehooligans.com/projects/wordpress/media-tags/comment-page-1/#comment-53028
June 11th, 2010 at 1:15 pm
hey hey! I found something weird with export/import of media tags.
wp 2.9.1 and media tags 2.2.7.
My Common media tags show up like this:
s:251:”a:1:{i:0;O:8:”stdClass”:9:{s:7:”term_id”;s:2:”21″;s:4:”name”;s:2:”4h”;s:4:”slug”;s:2:”4h”;s:10:”term_group”;s:1:”0″;s:16:”term_taxonomy_id”;s:1:”7″;s:8:”taxonomy”;s:10:”media-tags”;s:11:”descri
while my Uncommon media tags look perfect!
weird, eh?
thanks again for the plugin
June 11th, 2010 at 1:21 pm
@MadtownLems:
Ha. You are probably the only person to have used the export/import. Any chance I can get a copy of the export file? Would like to test with some real export data.
June 21st, 2010 at 4:40 am
Using version 2.2.9.1 with WordPress 2.9.2 if I reorder the images in the gallery either by dragging or changing the order numbers, the order doesn’t seem to save when I save changes. When I disable the plugin this works fine. Any ideas?
June 25th, 2010 at 12:10 am
I really like the plugin, and wonder if there’s a way to customise the shortcode to display just the links to the media it filters (rather than the images themselves)? I’m not a coder, but I’d really love to use this to filter PDF files into a ‘download list’ (text hyperlinks)
June 25th, 2010 at 7:48 am
@Dwayne: This is totally possible. When using the shortcode the default output format is list items <li></li>. One parameter you need to include in the shortcode is ‘display_item_callback’ and a function you write to handle the display of the link instead of the default image. Below is an example:
Here is an example shortcode. This may not be a match for your use
[media-tags media_tags="sometag" display_item_callback="my_display_links"]
In your theme’s functions.php add the following function. Note the function name ‘my_display_links’ matches the shortcode parameter name. Note with WordPress shortcodes the functions need to return instead of echo the output.
function my_display_links($item)
{
return ‘<li><a href=”‘.get_permalink($item- rel=”nofollow”>ID).’” title=”‘.get_the_title($item->ID).’”>’.get_the_title($item->ID).’</a></li>’;
}
Enjoy.
July 15th, 2010 at 5:25 pm
Thank you for this nice plugin…
I used it in a sidebar widget and noticed a strange behaviour in archive pages.. some media was not selected althoug it was there… I debugged around and my solution was the following:
around line 351
replaced
$query_str = ‘post_type=attachment&numberposts=-1′;
with
$query_str = ‘post_type=attachment&numberposts=-1&nopaging=1′;
This is becouse if the page is a archive page get_posts will use the paging settings from the main loop, unless we pass nopaging=1.
HTH
sergio
July 16th, 2010 at 8:43 am
“@MadtownLems:
Ha. You are probably the only person to have used the export/import. Any chance I can get a copy of the export file? Would like to test with some real export data.”
sending by email – export/import still wonked.
July 17th, 2010 at 2:59 pm
@sergio: Thanks for the comment. Not sure how to answer this but you may be correct. I’ve added the ‘nopaging’ parameter to the defaults but without a value. This means when you call get_attachments_by_media_tags() you can now pass in the ‘nopaging=1′ parameter which will get passed to this get_posts function. Look for this in an upcoming release of Media-Tags. And thanks for add the comment. and for using the plugin.
July 19th, 2010 at 12:22 pm
Hey awesome plug-in. I’m using MT version 2.2.8 with WP 3.0 – if I reorder the images in the gallery either by dragging or changing the order numbers, the order doesn’t save when I save changes. If i show image fields and edit the ‘menu order’ field however, the order is saved. When I disable the plugin the drag and drop ordering works fine. Similar to @Ben Huson above. Do you have any idea what is going wrong here? Thanks in advance for any help. Neil
July 19th, 2010 at 1:09 pm
@Neil: Thanks for the replay. This bug was identified and corrected in a new version. You might want to upgrade to the latest version of Media-Tags which is 2.2.9.2.
July 20th, 2010 at 5:23 am
Ahh! It’s on the list.. Thanks again Paul.
July 22nd, 2010 at 10:45 pm
Hi there
I have been searching for something like this for a while now.. THANK YOU for taking the time to develop it.
I have a question though.. I haven’t delved into the code yet, but I do have a few questions before I jump in and spend too much time with this..
Currently I am using the twentyTen theme. This is my first time working with this theme, but I understand that it works with thumbnails a little differently.
I currently have the ability to pull the first image of a post via category from wordpress and place it in my shopping cart’s pages.
What I would LOVE to be able to do is tag pictures as I upload them and then have them placed in the product pages based on their tags..
So if i have pictures of people wearing red shirts on my blog, I tag them with “red shirts”
then on my cart I pull them out by saying “show all images with the red shirt tag”
I’m not asking you specifically to write this for me, but more just can your plugin cover this type of application??
July 23rd, 2010 at 6:16 am
@Lindsay: Thanks for the kind comment. Much appreciated. I can give you the answers ‘Yes’ and ‘No’
Yes: The Media-Tags plugin was designed with a number of template functions where you can request image tagged with ‘red shirt’ or whatever. You find this functionality in the template function ‘get_attachments_by_media_tags()’. This function takes a number of arguments. For your purpose you would do something like the following:
get_attachments_by_media_tags(‘media_tags=red-shirt&post_parent=123′);
The ‘media-tags’ argument is the slug of the tag not the tag name. The ‘post-parent’ is optional. If not provided will return all images with the specific ‘media-tag’ What is returned from this function is a PHP array of items. Not knowing what shopping cart you are using I cannot advise on how to process the PHP array.
July 23rd, 2010 at 12:32 pm
WOW, thanks so much for your quick reply!! All too many times I end up on plugin pages where the owner hasn’t posted in months. Great job.
So the cart I am using is oscommerce.. I have managed to work with the thumbnail attachment on the home page of my osc install by using the theme “no” tag on the osc page but requiring the wp-load.. That allowed me to retrieve the get_posts and the bdw_get_images() .. Then I had the array like this:
// Get images for this post
$arrImages =& get_children(‘post_type=attachment&post_mime_type=image&post_parent=’ . $iPostID );
// If images exist for this page
if($arrImages) {
// Get array keys representing attached image numbers
$arrKeys = array_keys($arrImages);
$iNum = $arrKeys[0];
$sThumbUrl = wp_get_attachment_thumb_url($iNum);
$sImgString = ‘‘ .
” .
‘‘;
// Print the image
echo $sImgString;
}
}
?>
So I INTEND on doing something similarly with yours via the get_attachments_by_media_tags
I am fairly new at php and better at hacking things that people have already done than writing my own.. which is why i came here for guidance.
July 23rd, 2010 at 1:20 pm
@Lindsay: Thanks. I do try and keep up on user comment as much as possible. They generally have immediate needs.
From your code sample you can replace the call to get_children with the get_attachments_by_media_tags(‘media_tags=red-shirt&post_parent=123?); The returned array will be the same. Actually the Media-Tags plugin calls get_children internally after filtering by the tag slug. Good luck!
July 23rd, 2010 at 6:11 pm
Awesome Paul.. and THANK YOU!!
I will update you with how it goes. It seems there is a big movement over at the osc site to combine osc and wordpress.. If I can some how manage to create a form in osc which creates a new column in the product info table, then I will have the website admin create a product and put in the media tag that goes with that..
Then when the person views the product page, osc will automatically pull the content based on the tag associated with that product..
OYE, that sounds like a load of work.. Hah.. wish me luck!
July 23rd, 2010 at 6:31 pm
Hmm.. I have been playing with this.. I am not ENTIRELY sure what is going wrong, but here is my code:
ID;
// Get images for this post
$arrImages =& get_children(‘media_tags=bibst&post_type=attachment&post_mime_type=image&post_parent=’ . $iPostID );
// If images exist for this page
if($arrImages) {
// Get array keys representing attached image numbers
$arrKeys = array_keys($arrImages);
$iNum = $arrKeys[0];
$sThumbUrl = wp_get_attachment_thumb_url($iNum);
$sImgString = ‘‘ .
” .
‘‘;
// Print the image
echo $sImgString;
}
}
?>
I can definitely call for images, but when I add the media type, it does not seem to filter.. I also was having issues earlier because I copied and pasted my old code and forgot that the other code was only querying a particular category where with this I want it to pull from ALL posts but only pull from ones with the tag “bibs”
July 24th, 2010 at 9:52 am
@Lindsay: Again you should not be using the get_children WordPress function. I noticed you are adding the ‘media_tags=bibs’ parameters. This will not work. You need to call the Media-Tags template function like this:
$arrImages = get_attachments_by_media_tags(get_children(‘media_tags=bibst&post_type=attachment&post_mime_type=image&post_parent=’ . $iPostID );
Then see if the rest of the code you wrote works out. Also, to not clutter the commented please email me via the contact form. I’d like to take this PHP help offline. Thanks.
July 24th, 2010 at 6:52 pm
Thanks Paul… I attempted your fix but it did not quite work.. i will email you the details.
I do appreciate the help
August 1st, 2010 at 9:42 am
Hi there-
I’m a PHP/Wordpress newbie, so I apologize if this seems ignorant.
What I want to do is return two properties of images by tag. I would like the image url and the image caption to be returned.
How would I do this? If I use
$media_items = get_attachments_by_media_tags(‘media_tags=home’)
it returns an array with object in it (the ojbects that I need).
How would I access them?
August 1st, 2010 at 12:33 pm
@Shon:
Yeah this is simple PHP/WP coding. When you call get_attachments_by_media_tags(); what is returned will be an array of images. This is very similar to the posts array when you call the WP function get_posts(). To display the images you will need to code a PHP loop to process each image item.
Getting the image URL is not a clear question. As you should be aware WP supports different size images for each image you actually upload. So there is not one specific image URL but instead possibly 4 different ones.
Here is some quick code to get you started.
$media_items = get_attachments_by_media_tags(‘media_tags=home’);
if ($media_items)
{
foreach($media_items as $media_item)
{
//echo “DEBUG: media_item
“;
$image_src = wp_get_attachment_image_src($media_item->ID, ‘medium’);
// image_src[0] == image url;
// image_src[0] == image width;
// image_src[0] == image height;
// From here you will proceed to build the image HTML element and add the caption.
}
}
See the WP Codex:
http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src
August 3rd, 2010 at 8:53 am
Hi Paul
Thank you for this plugin. Looks promising.
How would I use the conditional testing? I’m trying to place it in a function in my functions.php file, but isn’t working.
This is the what I have tried.
if (is_mediatag(‘my-choice’)){
echo ‘My Choice’;
}
August 4th, 2010 at 4:03 am
First of all: thanx for the writing an supporting of this plugin.
I found a bug in this latest release and a way to fix it: when using an older (2.9.x) installation of WordPress, I got an error in the mediatags_rewrite.php: undefined function term_exists().
In line 84 and 154 this function is called and gave an error, but also in the function mediatags_position around line 185. In that last function, there is a check for WP 3.0 or else the fucntion is_term() is called.
I copied the check for the WP version to the other places where term_exists() is called and everything worked again.
Just to let you know for a next version or anyone with the same problem, keep up the good work.
August 4th, 2010 at 9:31 am
@Rene: Thanks. Yes, I’m aware of that bug. For some reason the folks who make the decision about the core function changed on the WP 3.0 release. I changed the plugin but didn’t notice they didn’t make the core change backwards compatible. This is handled better in the upcoming Media-Tags 3.0 release.
August 6th, 2010 at 2:20 pm
[...] ausgelagert, und für die heraldischen Begriffe benutze ich inzwischen in erster Linie die Mediatags vom Code Hooligan aus Austin Texas. Voriges Wochenende habe ich meine eigene Lösung mit den costum [...]
August 16th, 2010 at 9:25 am
If you’re trying to setup a search form for media tags use this code:
tag:
August 30th, 2010 at 4:00 pm
So I’m lookin’ to call $media_items = get_attachments_by_media_tags(…
Feeding it variables constructed from a form $_POST. I was thinking the code below should be in a seperate .php file, but I can’t get around the Call to undefined function get_attachments_by_media_tags()
function displayPhotos($photoTags, $photoCondit, $photoView) {
$media_items = get_attachments_by_media_tags(“‘media_tags=”.$photoTags.”&display_item_callback=”.$photoView.”&tags_compare=”.$photoCondit.”‘”);
if ($media_items) echo $media_items;
}
function make_thumbs($post_item, $size = ‘thumbnail’) {
$image_src = wp_get_attachment_image_src($post_item->ID, $size);
return ‘ID.’”>post_title.’” />’;
}
$pLen = count($_POST); //length of array
$numPost = array_values($_POST);
$tagArray = array_slice($numPost, 0, $pLen-2);
$photoView = “make_”.$numPost[$pLen-1];
$photoCondit = $numPost[$pLen-2];
$photoTags = implode(“,” , $tagArray);
if(isset($photoTags, $photoCondit, $photoView))
displayPhotos($photoTags, $photoCondit, $photoView);
August 30th, 2010 at 5:06 pm
@Brian:
First I’m not sure why you would get function not defined when calling ‘get_attachments_by_media_tags’. This function is located in the Media Tags plugin file mediatags_template_functions.php and is automatically included via mediatags.php
I do see something strange in your code. Though this might be some strange escaping from the comment form. It looks like you are mixing single and double quotes on the parameters to the function. Look at the very beginning of the of the parameters just before you ‘media_tags it looks like you are using a double quote then a single quote. That my friend will return nothing.
It might be easier to just build an array instead of building the link ampersand parameter list. Like this.
$media_tags_params = array(
‘media_tags’ => $photoTags,
‘display_item_callback => $photoView,
‘tags_compare => photoCondit
);
$media_items = get_attachments_by_media_tags($media_tags_params);
If you still cannot get the call to ‘get_attachments_by_media_tags’ working. Make sure first the Media-Tags plugin is active. I know this is obvious. But have to ask. You might try calling the object directly. This is basically what the stand alone function you are currently calling does. Like this.
function displayPhotos($photoTags, $photoCondit, $photoView) {
global $mediatags;
$media_items = $mediatags->get_attachments_by_media_tags($media_tags_params);
}
I have no comments to make on your $_POST variable processing.
August 31st, 2010 at 1:47 pm
There isn’t a corresponding get_the_mediatags() function call, but it’s what I wanted/needed. I added the following to the bottom of the mediatags_template_functions.php file:
function get_the_mediatags( $id = 0 ) {
return apply_filters( ‘get_the_mediatags’, get_the_terms( $id, MEDIA_TAGS_TAXONOMY ) );
}
August 31st, 2010 at 1:57 pm
@Burt: Great. Thanks for sharing your code. I’ll review and see about getting this added to the upcoming Media-Tags 3.0 release.
September 1st, 2010 at 1:40 am
I got it all figured out. It was just noob php problem. I needed to call wp-load before calling all the functions. Thanks for the reply, this is the best feature add I’ve found.
September 8th, 2010 at 6:37 pm
Media-Tags Beta Tester
I’m interested in bulk tag management from the media library for sure. It’s blowing my mind nobody has closed the loop on this yet.
October 13th, 2010 at 11:30 am
Media Tags + localization
The following link contains the latest version (2.2.9.2) adapted for i18n support, and po/mo files for the pt_BR language. Hope it’s useful.
http://drop.io/hpe2ykt
October 15th, 2010 at 2:34 pm
First off, great plugin!
Not sure if anyone else would find this useful, but I added code to the plugin to allow for the tag->description to be used so that I can display that text at the top of a media-tag archive page.
basically you just have to add the ‘description’ fields to the form creation in mediatags_admin.php, which i did by copying code from the category add/edit category forms, and then add ‘description’ to the array being sent to wp_insert_term or wp_update_term in mediatags_process_add and mediatags_process_update, respectively.
October 21st, 2010 at 6:47 am
@Justin: Thanks for the comment. You will be glad to know in the upcoming 3.0 release of the Media-Tags plugin the description field will be included.
October 21st, 2010 at 6:48 am
@Ricardo Tomasi: Thanks. You shouldn’t have.
October 29th, 2010 at 7:56 pm
Best you could change the webpage name title Media Tags CodeHooligans to more catching for your blog post you make. I loved the the writing yet.
November 9th, 2010 at 12:10 pm
Hey Again,
Just wondering how the next release is coming along. It looks like it’s been a few months since any changes to the SVN repo.
Do you need help testing any specific functionality or anything?
Just let me know! You’ve got my email.
- Jason
November 10th, 2010 at 5:09 pm
I really love this plugin! I am looking forward to the next release. In leiu of that, could you explain in n00b terms how to enable a short code to pull captions with the thumbnails?
Thanks for any help AND the excellent work!
November 14th, 2010 at 11:06 am
Media-Tags Beta Tester — please add me to the beta test of this. thanks!
November 25th, 2010 at 8:10 pm
@Kevin: Sorry for not replying earlier. Your comment got lost in my inbox.
To setup the caption via the Media-Tags shortcode is pretty simply. I’m sure there is a better method but here is my solution. In the Media-Tags shortcode you need to use the parameter display_item_callback=”mediatags_item_callback_with_caption”. The take the function below and add it somewhere like your theme’s functions.php file.
function mediatags_item_callback_with_caption($post_item, $size=’medium’)
{
$image_src = wp_get_attachment_image_src($post_item->ID, $size);
$output_str = ‘ID.’”>’;
// WP stores the Caption into the post_excerpt
if (strlen($post_item->post_excerpt))
{
$output_str .= ‘[caption id="attachment_'. $post_item->ID. '"
align="alignnone" width="'. $image_src[1] .’” caption=”‘. $post_item->post_excerpt .’”]’;
}
$output_str .= ‘post_title.’” />’;
if (strlen($post_item->post_excerpt))
{
$output_str .= ‘[/caption]‘;
}
return do_shortcode($output_str);
}
November 27th, 2010 at 11:49 am
Fantastic plugin! I’ve been using it alongside the in built WP categories to restrict downloadable content to certain users – works faultlessly!
One thing I have noticed however when using it with the new Beta of WP (3.1) – the ajax quick edit view for tag names and slugs encounters an error:
Fatal error: Call to undefined function register_column_headers() in /data02/c0277910/public_html/wp-content/plugins/media-tags/mediatags_admin.php on line 363
This isn’t a fault of the plugin, more that WP have deprecated some of the functions it uses. I’d love to see this bit of the plugin working if anyone can help out.
Cheers, Allan
November 27th, 2010 at 6:42 pm
@Allan Carruthers: Thanks for the comment. And right timely. I just uploaded an initial beta version of the Media-Tags plugin. And yes this beta version should work with the WordPress 3.1 beta just released. Other features of this beta version are support/integration with the WordPress nav menus, a new Bulk Admin interface and some other code cleanups. Please reply back if you find any issues. And thanks. You can download the plugin here http://www.codehooligans.com/packages/media-tags-3.0-beta-20101127B.zip
November 27th, 2010 at 6:44 pm
@Chris: Just released today. You can download the latest Media-Tags beta here http://www.codehooligans.com/packages/media-tags-3.0-beta-20101127B.zip
Thanks for using my plugin. Would appreciate any feedback on the beta. Thanks
November 27th, 2010 at 6:45 pm
@MadtownLems: Just released today. You can download the latest Media-Tags beta here http://www.codehooligans.com/packages/media-tags-3.0-beta-20101127B.zip
Thanks for using my plugin. Would appreciate any feedback on the beta. Thanks
November 27th, 2010 at 6:46 pm
@Justin: Just released today. You can download the latest Media-Tags beta here http://www.codehooligans.com/packages/media-tags-3.0-beta-20101127B.zip
Thanks for using my plugin. Would appreciate any feedback on the beta. Thanks
November 29th, 2010 at 3:30 am
@Paul Menard
Thanks for the speedy response! I’ve installed the beta release and it’s solved the Ajax issue. In doing so I’ve come across a new bug:
Warning: substr_compare() [function.substr-compare]: The length cannot exceed initial string length in /data02/c0277910/public_html/wp-content/plugins/media-tags/mediatags_admin.php on line 65
I’ve commented out lines 33-102 of mediatags_admin.php (turning off some of the new functionality) which has sorted the issue, albeit by turning off the problem! I’m not sure whether this has something to do with installing the beta plugin on a WP installation that was already running the other release? I’ll set up a fresh installation of WP Beta 3.1 this afternoon, pop the media-tag beta on and report back!
Thanks again for this.
Allan
December 3rd, 2010 at 7:02 am
Hi!
The WP media functionality is really horrible so you’re doing some very important work here!
I’m missing one functionality and that is being able to bulk-tag images instantly on upload. I mean picking one or more tags and then choose the files to upload. Do you think that’s even possible, are there any hooks that can accomplish that?
I would love to help out coding that functionality (cause i really need it), if you think it’s possible please give me a hint on how to get started. Thanks!
December 3rd, 2010 at 7:04 am
Also, i definitely will help you beta test this latest version!
December 4th, 2010 at 8:44 am
@Richard: The new Bulk Admin interface I’ve build for image upload is ready and would appreciate some testing. You can download it here http://www.codehooligans.com/packages/media-tags-3.0-beta-20101205.zip
There is one issue. The Bulk admin interface is not on the upload portion of the popup. Note the popup uses tab across the top. When you upload files on the first panel this page content is loaded via AJAX. Have not figured out a way to hook into that. But on the ‘Gallery’ tab you will see the options for the Media-Tags Bulk admin. The ‘Gallery’ tab contains all the image/media associated with the current post/page.
http://screencast.com/t/XmB9rGvwbb
http://screencast.com/t/rMDEhfTJa
December 7th, 2010 at 1:24 pm
Paul, fantastic plugin! Looks to be solving a number of issues we were having for a media gallery and how to create related items.
One issue I’m trying to solve…
is it possible to return a list of all tags of media items on a post page? Basically I’m trying to write a function that will display related posts to a gallery, listing posts that have LIKE tags to those of media tags set on gallery pages. none of the built in functions seem to take $page->ID as a parameter so I can’t seem to return a usable list.
thanks in advance for any help, and again great work!
December 7th, 2010 at 1:36 pm
@Justin: Thanks! There are actually two Media-Tags built-in functions to suggest. Both of these are located in the mediatags_template_functions.php file.
list_mediatags – This is the same function you would use to list out media-tags for the sidebar like a category listing.
get_mediatags – This is just a wrapper for the WordPress function get_terms();. This will return an array of the media-tags terms. You will then have to process the terms yourself. Processing includes building the output listing complete with links to terms.
Let me know if I can help on your development.
December 7th, 2010 at 2:02 pm
@Paul,
I tried those functions, but they seem to spit out ALL tags on the site (like the tag cloud), not just the tags on the images on my gallery page. perhaps i’m doing something wrong here?
December 7th, 2010 at 2:08 pm
Paul,
I’m also Beta testing the new v3.0, just wanted to give you a heads up on a Warning Error I just received:
Warning: substr_compare() [function.substr-compare]: The length cannot exceed initial string length in /path/to/wp-content/plugins/media-tags/mediatags_admin.php on line 393
this appeared on a PDF item that I went to add tags to (in the Media Library) and I have 7 active tags in my taglist.
December 7th, 2010 at 2:25 pm
@Justin: Maybe I’m not understanding how you have things setup. Can you email me direct on this. Keeps the comment traffic down. Also, I know about the bug(s). Seems there are a few I’m working on.
December 9th, 2010 at 11:16 am
Paul,
We upgraded our site to WP 3.0.3 and the Media Tags plugin to: Version 3.0.2.
The media tag option is now not showing up anywhere in our admin panel. Is this a known issue, or is there workaround?
December 9th, 2010 at 11:23 am
@Esteban: I’ve not had a chance in the last 24 hours to test WP 3.0.3 with the current version of Media-Tags (3.0.2). This should work since WP 3.0.3 was a security release. Did you upgrade with WP and the plugin at the same time? The new Media-Tags plugin 3.0 and higher uses the WordPress Roles system to lock out non-admin users. Are you logged in as admin? Do you see the Media-Tags options in the wp-admin left nav? Check under Media-Tags > Roles. Is this a single WP site or WP Multisite?
December 9th, 2010 at 4:06 pm
@Paul
We did the WP upgrade first, and then updated the Media Tag Plugin a day afterwards.
I am logged in as admin. I no longer see the Media Tags option under the Media category anymore. Also the Media Tags category is missing as well.
This is a single WP Site.
Thanks a lot for the help by the way! Not many developers respond so quick to help
.
December 9th, 2010 at 5:43 pm
@Esteban: Hmm. You still should see the Media-Tags under Media. Dumb question I have to ask. Is the plugin activated? Anyway possible to get admin access to the site? OR can you enable debug in your wp-config.php and let me know if you see errors.
define(‘WP_DEBUG’, true);
December 9th, 2010 at 5:59 pm
@Paul
Haha wow. I reinstalled the plugin, deactivated it, and reactivated it. It is now working fine.
It’s always the simplest solutions
.
Thanks a lot for the help!
December 9th, 2010 at 6:03 pm
@Esteban: Ah great. I need to try this on my end. I remember reading something about WordPress core making changes to the way plugins upgrade process works. Though I though this was not happening under WP 3.1. Guess it is time ti look into that. Thanks for using my plugin. And if you have comments on any of the newer features like the Bulk Admin or the Role management please post comments back to the site.
December 14th, 2010 at 7:25 am
First of all, thanks for this plugin that I’m using on many WordPress I created. It’s so useful !
Is there any know bugs with roles on WordPress multisite ?
I’ve got a WordPress configured in multisite (with just 1 site at the moment). The super-admins can add mediatags but the admins don’t. I’ve had a look at the “Media Tags Role Management”, but every roles are empty and I don’t get how I could add user to roles… Any help available for this feature ?
December 14th, 2010 at 7:33 am
@ghismo: Excellent. I can say that I tested on Multisite but this means I installed MU and created 2 sites and ran some tests. This is by no means a full production test of the roles. No one has reported issues with the Role Management system. You may be the first.
On each site by default the site admin should have full access to the Media-Tag options. Is there any way for me to view the system? Or can you provide screen shots of the Role Management page for normal users?
December 14th, 2010 at 8:07 am
Paul, thank you so much. Just upgraded to Media Tags 3.0.2 and the issue is gone ! Thanks for your time, and sorry for the fuss…
December 14th, 2010 at 2:14 pm
Maybe an amateurish question, but how do I get taxonomy-media-tags.php to display more than the default number of posts? query_posts() doesn’t seem to be working, or I’m using it wrong.
Plugin continues to be most excellent, by the way.
December 14th, 2010 at 2:27 pm
@Gryph: Glad to hear of someone using the taxonomy-media-tags.php. Since this is a ‘standard’ WordPress template as you have found out it uses the default number of posts per the Settings > Reading settings.
To override the number you will need to add something like
query_posts(‘posts_per_page=5′);
to your template before the loop is executes. See the WordPress Codex for the details on query_posts http://codex.wordpress.org/Function_Reference/query_posts
December 14th, 2010 at 3:05 pm
Oh hey thanks, got it fixed. Turns out I was replacing the query string instead of just tacking an argument onto it. I can read…!
December 14th, 2010 at 5:02 pm
well this is a shame…. I used to be able to search through my media tags by adding ‘?s=search term here’ to the end of the URL of /media-tags/some-tag/ but it seems that as of this latest version, that no longer works.
Any suggestions for how to get WP to let me insert a search form to only search within certain media tags?
December 14th, 2010 at 5:05 pm
to add.. I first discovered the original search feature randomly, and commented on it in this blog with comment #57.
December 14th, 2010 at 7:27 pm
@Carlos: My apologies for breaking something. I had no idea this was being used. The is most likely a side effect of removing all the hacked together code for the custom rewrite. Media-Tags 3.0 now uses the rewrite logic provided by default for a registered taxonomy. Let me look at this I might be able to provide a quick-ish solution.
December 14th, 2010 at 7:34 pm
@Carlos: I just checked on my dev server. There I have the latest version of Media-Tags (3.0.2) and the latest version of WordPress (3.0.3)
I have a media-tags term setup ‘flags’ which have 15 or so images associated with it. You can see the Media-Tags archive
http://wp303.codehooligans.com/media-tags/flags
If I add a search to the end of the URL it does appears to search. For example adding a search for ‘fr’ will filter the listing to display the ‘France’ flag. Give it a try on my dev server.
http://wp303.codehooligans.com/media-tags/flags?s=fr
December 15th, 2010 at 6:12 am
Thanks Paul! I’ll need to investigate this further, then.
You are using the twenty ten theme?
Do you have a custom taxanomy-media-tags.php enabled or are you using the default WP listing?
December 15th, 2010 at 6:40 am
…let me add. Using the Twenty Ten theme does not help my situation.
I just temporarily turned it on, and /?s= does not give me results.
Will continue to investigate.
December 15th, 2010 at 6:41 am
@Carlos: Correct this is an out of the box TwentyTen theme. Very minimal just for testing. The site has only the default page and post created via the initial WordPress install. And yes I added the template ‘taxonomy-media-tags.php’ to the TwentyTen theme folder. When you view the Media-Tags Flags archive (http://wp303.codehooligans.com/media-tags/flags/) you can see this is displayed as debug information. But note when you add the search (http://wp303.codehooligans.com/media-tags/flags/?s=fr) the search.php template is used not the taxonomy-media-tags.php. Hope this helps.
December 15th, 2010 at 6:43 am
@Carlos: Is this a public site where I can see things?
December 15th, 2010 at 6:53 am
Seems to be tied to the Relavanssi plugin I have. It is a search ‘improver’. When it is disabled, I get *some* results back, but these are not wholly accurate results.
It does show results only from the media-tags taxonomy.
It’s actually an odd batch of results, filtered by some other attribute.
December 15th, 2010 at 7:10 am
@Carlos: Ah. I guess the obvious question is what other plugins are you running which may impact the results?
December 15th, 2010 at 7:31 am
Ok… this is cool. Did some more digging.
The search results aren’t entirely accurate — on your site or mine.
Essentially, the search results are searching through all your site’s media attachment pages, but they aren’t actually searching through term-specific media-tags
A few things:
- adding /?s=term to the end of a /media-tags/flags/ page is the same as adding /?s=term&media-tags=flags to the root of your site
- though we are requesting WP to search through the taxonomy media-tags, it is only searching through attachment pages that contain matching titles and captions — it is not filtered based on the media tag term we are specifying
I think your dev site lacks enough content to discover that fact.
You can find my media-tag tag listing here: http://news.health.ufl.edu/media-resources/photo-library/
…we have thousands of posts, so it made it easier to see how the search results weren’t correct.
e.g., search through the buildings listing, and you will receive results of images that are not in that specific media tag, but are media attachments none the less.
I will leave my Relevannsi plugin off for a little bit so you can see some of these results.
December 15th, 2010 at 7:38 am
just to clarify: adding the &media-tags=flags bit to a search URL will filter results that are media-tags, but not necessarily tagged as ‘flags’. It will simply search through ALL media-tags
December 15th, 2010 at 7:47 am
@Carlos: Thanks for the digging and the details. I understand the issue. View the WordPress hooks I can intercept the processing of the search and have it search the way I want. But I’m a little confused on what the results should be. If I know the taxonomy is ‘media-tags’ and the term is ‘flag’ what should be searched if not the attachment title, etc.
December 15th, 2010 at 7:54 am
I would say it should search the:
- title
- caption
- description
..for each attachment, in that taxonomy, with that term.
I feel like this is what it used to do before the taxonomy upgrade.
December 15th, 2010 at 8:05 am
@Carlos: I’ve setup the older version of Media-Tags 2.2.9.2 on a previous version of WP http://wp302.codehooligans.com/media-tags/flags This site has a similar set of Flag images uploaded to a single post and tagged via Media-Tags as ‘flags’.
On both wp303 and wp302 I’ve taken the France flag and made changes. I set the title = ‘xxx’, alt text = ‘yyy’, caption = ‘zzz’ and description = ‘aaa’.
When I run the search for each of these on the wp303 I only get hits on the title (xxx) and description (aaa)
http://wp303.codehooligans.com/media-tags/flags/?s=xxx returns France image
http://wp303.codehooligans.com/media-tags/flags/?s=yyy returns nothing
http://wp303.codehooligans.com/media-tags/flags/?s=zzz returns nothing
http://wp303.codehooligans.com/media-tags/flags/?s=aaa France image
When I run the same searched on the wp302 (running Media-Tags 2.2.92) I also only get hits on the title (xxx) and description (aaa)
http://wp302.codehooligans.com/media-tags/flags/?s=xxx returns France image
http://wp302.codehooligans.com/media-tags/flags/?s=yyy returns nothing
http://wp302.codehooligans.com/media-tags/flags/?s=zzz returns nothing
http://wp302.codehooligans.com/media-tags/flags/?s=aaa returns France image
I’ve also enabled some debug output so I can see what WordPress is doing for the query on both sites. From what I can see in my limited data the results are the same on the older version of Media-Tags and newer one.
What am I missing?
December 15th, 2010 at 9:30 am
Add another media tag (not flags) with another file in it. If it shares the same terms, it will appear in the results. That’s the issue I’m having.
Even if an attached image is not tagged the same, it will show up in the results.
December 15th, 2010 at 9:31 am
(it will appear in the results if it shares common search terms)
December 15th, 2010 at 9:40 am
@Carlos: Thanks for that. I loaded some flower images into the dev sites. On each site I changed one image to have the same title, alt text, caption and description as the France flag. On the http://wp303.codehooligans.com/media-tags/flags?s=xxx running the latest version of Media-Tags it shows both the France and Wildflower image (FAIL). On the http://wp302.codehooligans.com/media-tags/flags/?s=xxx site running Media-tags 2.2.9.2 is shows only the France image (SUCCESS).
So now that I see the issue I need to figure out how to get this working. For now you might want to downgrade the plugin since your site is built upon that search ability. Sorry. Hope to have a solution soon.
December 15th, 2010 at 9:48 am
No worries. I’m just very grateful that you’re willing to examine the issue.
December 15th, 2010 at 10:36 am
@Carlos: No problem. Always glad to look into issues. So I have a patch. Can I sent you a file to change on your site? Send me an email to paul [at] codehooligans [dot] com.
December 16th, 2010 at 12:41 pm
Quick question: does this also work for videos that I have stored in my Media Library?
December 16th, 2010 at 12:46 pm
@Achim: Of course. Any media items uploaded into WordPress. So images, documents, PDF, Word Document, Flash flv file, mpeg video files can all be tagged using the Media-Tags plugin.
December 17th, 2010 at 4:54 am
Thanks Paul. I’ve just tried it and I’ve run into problems.
Let’s say I have a jpg and a an mpeg tagged ‘blue’ and I put in ‘[media-tags media_tags="blue" numberposts="5"]‘.
The result is: ”
”
What am I doing wrong?
December 17th, 2010 at 4:56 am
OK, apparently I can’t post code here.
Well, the result is: the image shows up, the mpeg does not. Instead of the mpeg, I get an empty img src=”".
December 17th, 2010 at 6:59 am
@Achim: The issue is that images are known file types for display. Meaning with .gif, jpg and .png files the display wrapper for these can be dynamically generated. For mpeg movies these are not as simple. I don’t think WP has a built in object wrapper for non-images.
My suggestion is to look into the Media-Tags shortcode parameter ‘display_item_callback’. This will let you setup a function which you can control the display. There are example of the callback function in the mediatags_shortcodes.php files in the plugin folder. Basically in this function you can check the type of the item. If it is an mpeg you can provide your own bject code to wrap around the mpeg for display.
Look for the details under the Media-Tags help in your wp-admin
December 17th, 2010 at 8:18 pm
maybe a known issue, I figured I’d leave it here just in case (I can only find one instance of ‘numerical’ on this page and it doesn’t seem to be related)
tl;dr: http://dl.dropbox.com/u/1758051/dis%202.avi
Tag names that are completely numerical don’t seem to take IF they’re added through a checkbox on the edit attachment page. (Strangely, they’ll un-take just fine if you *un*check them.) Putting them in the text field works fine. Using the checkbox in the bulk tagger you added with this latest big revision also works fine.
December 17th, 2010 at 9:47 pm
@Gryph: Hmm. I will definitely look into this. Thanks for brining this to my attention.
December 18th, 2010 at 1:52 am
Is there an easy way to exclude mediatags related to unpublished posts from the list_mediatags() function? It works almost exactly how I want it to, except that it exposes mediatags for draft posts that I haven’t made public yet.
December 18th, 2010 at 1:55 am
And on a separate note, is there an easy way to list all posts which have images that have been tagged with a specific mediatag? I’m trying to make it so that the mediatag archive pages don’t show individual images/attachments, but instead list their parent posts. I got something close to what I want, but it involves doing queries which seem extraneous.
By the way, thanks for all the work on this!
December 18th, 2010 at 7:18 am
@Gryph: I think I have this solved. I have some other reported issues to investigate but this bug should be fixed int he next Media-Tags release. I don’t recall this specific issues being reported. Or at least not reported as detailed as you have done. Thanks for the video. This makes all the different in seeing what the exact issue is.
December 18th, 2010 at 7:22 am
@Nick: That is an excellent issue. In thinking about it this morning it make perfect sense to exclude tags for attachments whose parent posts are not published. This will involve some deeper coding then just using the WordPress function to list the tags for the Media-Tags taxonomy. I’m not sure I’ll have an immediate solution. But hopefully soon. Thanks for brining this up.
December 18th, 2010 at 2:42 pm
Glad to be of any assistance! Any thoughts on the other question I had about having the mediatag archives list parent posts instead of images/attachments?
December 19th, 2010 at 3:47 pm
@Nick: Not really. See the reason the plugin was developed was provide a way to associated a tag to an image. For posts you already have categories and post tags. So after thinking about this over the evening in order to pull posts that contain attachments that are tagged would be sort of convoluted to implement using the standard WordPress Taxonomies. So at the moment I’m still peculating on the idea. Sort of like other user ideas that the plugin should take arguments to scale and crop image. The cropping and scaling of images is not something I considered core to the plugin functionality of tagging attachments. There are many other plugin that handle the image manipulation quite well.
December 30th, 2010 at 9:04 pm
Hey Paul – great work on the plugin, a valuable addition to the wordpress platform!
I’m attempting to create a gallery – displaying not only images, but also the image titles, captions, and descriptions – is this possible?
I’ve searched the comments, and haven’t found an approach that would work – if anyone could point me in the right direction, that’d be amazing – thanks!
Reed
December 31st, 2010 at 6:17 am
Paul, It was a pleasant surprise to find this plugin and your name attached to it. Nice work and I agree w. others it belongs in core in some shape or other.
Reed: The tag-gallery plugin uses media-tags and supports captions. Its pretty simple and even if it doesn’t do everything you want, it might be easy to extend to fit.
December 31st, 2010 at 7:30 am
@Sam Foster: Hey Man! Always glad to hear from you. Thanks for the comment. Glad you enjoy my little plugin.
December 31st, 2010 at 8:04 am
@Reed Enger: You can follow the advice of Sam Foster which is to use the tag-gallery plugin. Or if you want to code your own (warning PHP knowledge needed) you can just pass in the ‘display_item_callback’ parameter. This parameter is available if using the Media-Tags shortcode or calling the get_attachments_by_media_tags function.
In either case you need to setup your own function. Look at the bottom of the mediatags_shortcodes.php file. There are two examples of callback functions. One even shows how to get the attachment caption. Be sure to copy these as they are examples only and may change. Just copy the function into you theme’s functions.php file. Name is something else. Then pass that function name as the value for the ‘display_item_callback’ parameter.
Within the function you can change whatever you need. The function will be called for each gallery item found. Meaning for each individual image. Within your function you can do different things like wrap the image with the caption of other div code so that it fits your theme/gallery layout needs.
After thinking about how complicated this process is I might do a full write up as a new blog post on this site explaining how to setup a gallery using the Media-Tags plugin.
December 31st, 2010 at 4:34 pm
Paul – Thanks for the quick and helpful response!
I’m very new to php, so working up the new function will be an admirable challenge – but thanks for the guidance!
If you eventually have time to write a post about gallery construction, I’ll be a very grateful reader!
January 5th, 2011 at 11:23 am
Hello Paul,
Thank you so much for this plugin.
I got it to work for my tag pages and it works beautifully.
However, I am having an issue getting it to work for the search.php page.
I have the code placed within the loop and it does not return anything.
I am using Search Everything plugin as well to also search through attachment tags and such.
Do you know why this code wouldn’t return anything?
$media_items = get_attachments_by_media_tags(‘media_tags=’.$search_term.’&post_parent=’.$postid);
January 5th, 2011 at 12:01 pm
@James: Thanks for the comment. Glad you are enjoying the plugin.
On the line of code you provided I can’t really answer if this will return an tags because I don’t know the value of ‘search_term’ or ‘postid’. As I’m sure you are aware the post_parent should be used to limit the media-tags function to that specific post ID. I’m not sure how your doing the search form but mostly that is global. Then again maybe you have a search form on each of the gallery page and want to allow search within that gallery only.
Best advice I can give is setup the function in a page template and run some tests on calling the get_attachments_by_media_tags function with different values until you reach the desired results.
I’ll be here if you need some help.
January 11th, 2011 at 1:37 pm
So say I add some tags to some PDFs… why cant I use query_posts to make them display on a similarly tagged post?
January 11th, 2011 at 1:39 pm
Doh! Figured it out – needed to use media-tags=tag in my query_post.
January 11th, 2011 at 1:41 pm
@Fred: Ah great. Was just about to respond to you other comment. Since Media-Tags uses the supporting Taxonomy infrastructure of WordPress you can use get_posts, get_terms, and all the other taxonomy related function. By sure to set the taxonomy to media-tags. Enjoy.
January 13th, 2011 at 3:24 am
Hi Paul,
Is it possible to remove “Media-Tags” from the title tag page? Example : http://www.lacertilienne.com/facette/performances/
I use the All in One SEO plugin, maybe it could help…
Thank you a lot
January 13th, 2011 at 8:26 am
@Laetitia: Thanks for using my little plugin. There is not currently a way to control the HTML title. At current this defaults to the WordPress format of | | . On my development site I installed the All in One SEO Pack plugin. I see on the settings page an option to control the format of the Category page title but that is it.
I will look into doing something via the plugin. In the mean time if you want to manage this you can control the title via your theme’s header.php. It would take some PHP knowledge. Let me know if you find a simpler solution. Or let me know if you need help on tweaking your header.php
January 13th, 2011 at 12:15 pm
I’ll wait for your development, it’s not urgent. Thank you for your diligence, I really appreciate your plugin
January 21st, 2011 at 1:21 am
Hi Paul,
Great plug-in man!
I was just wondering if you know of a way to integrate the plug-in wp-pagenavi with your plug-in?
January 21st, 2011 at 12:50 pm
@Steve: Thanks for the comment. I’ve not really considered integration with this plugin. For what purpose I’m wondering? Seems this plugin handles the pager display. So instead of the normal Previous/Next links you get a nice google-type pager nav. This plugin can be added to the WP system without need to integrated directly into Media-Tags and used for the Media-Tags archives pages. Unless I’m missing something.
January 21st, 2011 at 1:04 pm
Thanks for such a great plugin, I am having problems trying to work out how to exclude a media_tag. I have managed with a custom select query but would really appreciate such a function available either within your get_attachments_by_media_tags or the shortcode media-tags. Any help greatly received
January 21st, 2011 at 2:08 pm
@FB: Thanks for the comment. I’m not quite sure what you mean about excluding a media_tag. When you call the get_attachments_by_media_tag function you are passing in the media-tags term(s) you want to query. So only items you want are returned. Like this:
$all_tag1_items = get_attachments_by_media_tag(‘media_tags=tag1′);
What am I missing or not understanding from your comment?
January 21st, 2011 at 3:49 pm
I added the short tag. I have a bunch of PDFs. The list I get doesn’t link to the item, or to anything–it shows src=”" and width=”" height=”" –TITLE does have the name of the item.
Can I get it to output a list of links to the items? What outputs this list?
Thanks a bunch!
e.g.
January 21st, 2011 at 3:50 pm
Example:
[li class="media-tag-list" id="media-tag-item-50"] [img src="" width="" height=""title="Top 10 Tips for Cost-Efficient Backup & Disaster Recovery" /] [/li]
January 21st, 2011 at 8:15 pm
@JamesPr: Yes, you can build you own output function. The plugin does not automatically build a link to the file. There are just too many filetype to consider. And Wp does not offer a standard way to do this. Image are pretty simple and standard.
As mentioned on the notes for the plugin and many comments on this page you can pass the parameter ‘display_item_callback’. This parameter value is a function of your choice. Into the function you will be passed each media-tag item per the other shortcode parameters. Take a look at the file mediatags_shortcodes.php. At the bottom there are two example of the function. Make a copy of one of these into your own theme’s function.php. Also you need to be sure and change the name of your new function to something unique.
January 22nd, 2011 at 12:09 am
@Paul: Yip you are right all it does is paging. I’ll put it in conext for you: In the theme I’m building I have a custom page (and the Media-Tags archives pages) which displays a number of images using get_attachments_by_media_tags(‘media_tags=whatever&numberposts=10′. There will probably more than 10 images uploaded I was trying to implement paging. Since I’ve been using wp-pagenavi throughout my theme I was trying to use it here as well, for consistency. I see that there is an offset option on your plugin so maybe I’ll just use that and just build the paging myself
Thanks!
January 22nd, 2011 at 10:45 am
@Steve: Yeah I guess I can see your point. I know many users of Media-Tags use the short code for example and this may output too many items all at once. Would be better to offer an option to page the output within the content. Let me know if you want to share your code. Would love to see this work. Now you have me interested.
January 24th, 2011 at 11:38 am
Thanks for the quick reply..
I understand what you said and it is my fault for not explaining myself correctly:
eg I have two images tagged like so
image1 tags = “exhibitionname, artist-name, workindividualname,”
image2 tags = “exhibitionname, artist-name, workindividualname,”
image3 tags = “exhibitionname, artist-name, buildingexhibition,”
if i search for images tagged exhibitionname + artist-name
I will get three images
so what happens when I want to show only tags exhibitionname, artist-name and exclude the tag buildingexhibition tag
thanks in advance I hope that you understand me now
atb
January 24th, 2011 at 2:58 pm
@Paul: Thanks for your reply. To edit how the list is output so it includes a link to the media, I created another function like mediatags_item_callback and [a href="/?attachment_id='.$post_item-ID.'"]
January 24th, 2011 at 3:00 pm
Question:
I want to have a page display items matching two tags–”BLUE” AND “WIDGETS” (not OR) and I need it to have its own URL.
With regular tags, I can do website.com/tag/blue+widgets/
How can I do the same thing with media tags?
January 25th, 2011 at 10:46 am
Have you given any thought to making the tags hierarchical? I know WP’s custom taxonomies support it natively, but I imagine all the code around editing/applying Media Tags would need to be updated to support it.
Mostly I’m looking for the ability to have URLs like /media-tags/screenshots/fooga that will use a taxonomy-media-tags-screenshots-fooga.php template if it exists & if not fall back to taxonomy-media-tags-screenshots.php
January 25th, 2011 at 10:58 am
@Pat Cavit: Yeah. Actually have been thinking about this more and more. Though would need to change the name to Media-Categories instead of Media-Tags. Since the ‘Tags’ part is supposed to be similar in functionality to post ‘tags’. Might just come up with a clone of the plugin.
January 25th, 2011 at 11:30 am
@JamesPr: This is not currently possible. The Media-Tags plugin uses the rewrite system from WordPress and from what I can tell only one ‘term’ is allowed at the moment. Meaning like the default post categories and post tags you can only have one in the permalink at a time. There has been talk about some future support for this. But nothing on the near horizon that I can tell. I know there are posts from other developers who have hacked together some code to user multiple terms but I’ve not seen anything that I like and that is clean.
January 25th, 2011 at 11:45 am
@FB: Ah yeah. You know this is not something actually requested before. But not that I read your comments it seems like something common. I’ll need to think about this. Hope to have something in the next release.
January 26th, 2011 at 9:00 am
@JamesPr: Just did some checking in the WordPress Trac system. Seems the support for multiple terms archives via the URL is part of the upcoming 3.1 release http://core.trac.wordpress.org/ticket/12891 I’ve tested Media-Tags with my local 3.1 beta 2 release and it does work. The accepted format of the URL is to use plus sign to indicate and ‘AND’ join or a comma to indicate an ‘OR’ join.
So from your example the URL would be something like
http://www.yoursite.com/media-tags/blue+widgets
Hope this helps.
January 26th, 2011 at 9:04 am
Thanks for replying, I ended up using a custom select query and tax not in. I had to get the project out of the door… Keep up the good work with this plugin
January 31st, 2011 at 10:43 pm
Love the plugin, but I have one request for the next version, are you able to filter by multiply tags? i.e filter all media by red + car
February 1st, 2011 at 6:53 am
@Random: Well you are in luck. Coming in WordPress is the ability to have this on any Taxonomy. The logic will be if the terms are joined by a comma like ‘red,car’ this will be an OR search. If the terms are joined by a plus sign like ‘red+car’ this will be an AND search. I don’t see the point of adding this custom code to the Media-Tags plugin when WP 3.1 is about to be released.
February 1st, 2011 at 11:31 am
I am curious to find out what blog platform you happen to be utilizing? I’m experiencing some small security issues with my latest site and I’d like to find something more risk-free. Do you have any recommendations?
February 1st, 2011 at 3:07 pm
I have a MU installation running with an external URL (not a subdomain or subdirectory), and cannot seem to get the Media Tag menus in the backend interface for the external URL unless logged in as a Super Admin. I can access the Media Tag menus in the backend for the primary install as a regular Admin (not Super Admin), and am using the WordPress MU Domain Mapping plugin for the external URL. How can I access the Media Tags menus as a regular Admin in the backend of the external WP website?
February 1st, 2011 at 3:32 pm
@Harris: Great. Have been waiting to see if the plugin works under MU. So under super admin do you see the Media-Tags menu section? Do you see the Roles panel? In this panel are the users listed? If so have you tried granting permissions to non super admin users?
February 1st, 2011 at 3:52 pm
That did it Paul! Once I checked it on the external site’s backend as a superuser, I was able to see the other users and grant them access. Thanks so much!
February 1st, 2011 at 4:23 pm
@Harris: Oh Awesome! I guess I need to figure out how to setup the admin users for each blog not just the super admin to access the options. Glad this works now.
February 4th, 2011 at 12:21 pm
Is there a way to create an archive-like template that displays all media-tagged items. I’m using Media Tags for some resources and would like to display them all.
So, for instance, when I go to /media-tags/, I don’t get a 404 – I get EVERYTHING that has a media tag. Any ideas?
February 4th, 2011 at 1:05 pm
@Fred: There is not a good way in the current WordPress version to accomplish this. See Media-Tags is a Taxonomy. So it functions like the built in WordPress category and post-tags Taxonomies. So there is no support for displaying a base Taxonomy archive like http://www.yoursite.com/media-tags/ Just like you cannot access the base Category archive http://www.yoursite.com/category or http://www.yoursite.com/tag
What you can do it create a Page with the slug /media-tags/ Then create a page template. You can for example show the Media-Tags tag cloud by adding the function mediatags_cloud().
Hope this helps.
February 4th, 2011 at 1:15 pm
So I’ll create a page template and grab all media-tagged items… with query_posts? Can I do that?
February 8th, 2011 at 1:24 pm
Great plugin – thank you!
Any chance of adding an ‘All Unassigned’ menu item to the filter on the Media Library page?
It would help when initially adding tags to all my untagged items, instead of searching through pages and pages for items scattered everywhere.
On an unrelated note… I did see one glitch I thought I’d mention. I installed 3.03 awhile back and just now started to use it. I noticed that no options appeared anywhere in WP — not even a ‘Media-Tags’ link under ‘Media’ in the sidebar. I deactivated the plugin and re-activated it and everything is working fine now.
Thanks
Paul
February 8th, 2011 at 1:29 pm
@Paul B: Thanks man! Thanks for the comment.
I’ve had other requests for to somehow show the unassigned. Since Media-Tags works like WP Categories and Post Tags I’ll need to see if there is a way to filter and display this.
And yeah I’ve heard there were changes with the way WP handled the upgrade of plugins. About half dozen users got caught with the need to deactivate then reactivate the plugin after a plugin and/or WP upgrade. I’ll investigate.
February 9th, 2011 at 8:56 pm
hey paul,
thanks for the plugin, its cool and very helpful!
i know nothing about programing and just cant get the media tag cloud work. basically i would like my photos to be pulled by media tags through the cloud and displayed in gallery using cleaner gallery+lightbox script.
can you please explain this in a very simple way?
thank you!
steve
February 16th, 2011 at 3:49 pm
What parameters can you use with the argument: orderby ?
Thanks for a great plugin!
February 18th, 2011 at 7:12 am
query_posts should work with multiple media-tags, right?
query_posts(“showposts=10&media-tags=history,healthcare”);
Not working. Have items tagged to those tags.
February 18th, 2011 at 7:16 am
@Fred: My understanding is multiple term query on a taxonomy is not until WP 3.1 Check the WP Codex for query_posts
http://codex.wordpress.org/Function_Reference/query_posts#Taxonomy_Parameters
This is not something under my control. Also in 3.1 you will be able to query multiple terms via the URL like
http://www.somehost.com/media-tags/tag1,tag2,tag3 (the comma indicates an OR search)
http://www.somehost.com/media-tags/tag1+tag2+tag3 (the plus indicates an AND search)
February 18th, 2011 at 8:29 am
I bet I could grab them with get_results and a custom query. Hmm.
February 18th, 2011 at 8:44 am
@Fred: Well if you do get this working please post back and share the how-to with others. I know there are a few trying to do multiple term queries.
February 19th, 2011 at 10:55 pm
Is it possible to use get_attachments_by_media_tags to display a list of images, and also link those images to the media tags url (the media tags archive page – not the image)?
I’m not very php savvy so any help is appreciated. Thanks!
February 22nd, 2011 at 11:55 am
I am using a custom callback function in which I am calling the thumbnail size ($size=’thumbnail’). But my images are still showing up as medium images. I’ve checked that Media-tags is calling the custom callback (and it is, in fact the other modifications I made are working). I tried “large” just to see if that would work and it does not. Does anyone else have problems with different image sizes? Any ideas how to get this working?
February 22nd, 2011 at 12:00 pm
@Mike: One way to tell is by echoing out the size parameter value within you custom function. Also please post your custom function code here for review.
February 22nd, 2011 at 4:42 pm
I can create a numeric media-tag, just as I can a post tag. i.e. “2010″, “2009″, etc…
But, when I apply it to a media item, it is not applied/retained.
Current workaround is to create a media-tag “y2010″, apply that to the media item(s), then rename the media-tag to “2010″.
February 22nd, 2011 at 5:46 pm
Followup to my previous post…
You can have a tagname that is purely numeric as long as the slug is not purely numeric, so my new workaround is to make the slug “y2010″ for the tagname “2010″.
Also, it is not clear in the help that the “flags” for the media_tags shortcode attribute are the slug, and not the tag itself…why is the term “flags” used at all? The term doesn’t seem to be defined anywhere in the help.
Regards!
February 23rd, 2011 at 12:36 am
It would be nice when bulk uploading media to specify the tags for the set of media BEFORE the upload, as it is tedious to do this for each item individually after the upload.
I realize you can use the bulk items in the Media Library after uploading, but then you have to query the items and hope you don’t miss any or tag something accidentally.
Regards!
February 23rd, 2011 at 6:17 am
@Tom: Hmm. this is not right. You should be able to create whatever tag name or slug just like with normal post tags. I’ll investigate before the next release.
February 23rd, 2011 at 6:19 am
@Tom: Thanks for sharing the work around. But in my opinion not a best solution.
February 23rd, 2011 at 6:20 am
@Tom: I agree. However on that upload tab there are no hooks for developers to use. That whole section is Flash. so there is no ability to hook into page events like on other sections of WordPress. So best I could do was add the bulk admin section after the upload had occurred.
Thanks!
February 23rd, 2011 at 6:29 am
@Tom: Back to this comment. I disagree. I just tested Media-Tags on a recently installed WP 3.0.5 site running Media-tags 3.0.3
I can create a new Page, upload an image to that page and via the media popup set the media-tag to ’654321′. I can also go into the Media > Media-Tags tag management page ad create a new tag ’123456′. Finally I can go to Media > Library and both upload new image or tags existing ones with pure numeric tags.
So questions back to you are
What version of Media-Tags are you running?
What version of WordPress are you running?
What other plugins are you running?
Under Posts > Post Tags can you create a pure numeric tag?
February 24th, 2011 at 6:33 am
I was able to get this to work in some other cases, but not others. Let me break down the scenarios.
1) I CAN create an all numeric media tag.
2) I CAN create(and assign) to media using the bulk operations.
Here is the initial scenario I tried where it did not work:
1) Create a numeric media-tag. (In my case, 2010)
2) Go to edit an existing media item,
3) Check the “2010″ media-tag checkbox.
4) Click “Update Media”.
5) Observe the Media Library, media-tag column.
6) Notice that the tag doesn’t show up.
6) Edit the existing media-item again.
7) Notice the checkbox for “2010″ is not checked.
WP 3.0.5
MT 3.0.3
Other plugins: Connections, jQueryColorbox, NextGEN Gallery, Postie, Post Type Switcher, qTranslate, SEO Ultimate, WP System Health , WPTouch.
Bummer about the bulk upload part. :-/
February 24th, 2011 at 7:24 am
@Tom: Ah. Thanks the the break down. Sorry just was not seeing the issues. But I am now. This should be fixed in the upcoming release. Yeah agree bummer on the bulk upload. Maybe some changes in 3.1 which was just released. Will need to check f there is now a way into that process. Thanks.
February 24th, 2011 at 7:51 am
Returns post from multiple tags query:
2
3
4
5
6
7
8
9
10
FROM wp_posts
INNER JOIN wp_term_relationships ON ( wp_posts.ID = wp_term_relationships.object_id )
INNER JOIN wp_term_taxonomy ON ( wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id )
INNER JOIN wp_terms ON ( wp_term_taxonomy.term_id = wp_terms.term_id )
WHERE 1 =1
AND wp_term_taxonomy.taxonomy = \'media-tags\'
AND wp_terms.slug
IN (' . $_tags . ')';
$tagged_posts = $wpdb->get_results($query_string, OBJECT);
February 24th, 2011 at 12:53 pm
Paul,
Still working with your plugin, finding new ways to implement it across some sites I’m working on. Right now we are running into an issue where we really need to do a comparison of tags based on the ‘name’ (not the slug). You have the ‘search_by’ attribute, but according to this page’s documentation, apparently it only currently supports ‘slug’? Have you been working on this by any chance, or at least could you point me in the right direction of getting this working properly?
Thanks in advance for any and all help, and again, awesome plugin!
February 24th, 2011 at 1:05 pm
@Justin: Well see the term ‘name’ is not always unique. If you try to create two Media-Tag terms ‘Flag’.One will have the slug ‘flags’. The other will have a slug ‘flags2′ or similar. But both can have the name ‘Flags’. This is just not something WP uses for uniqueness. So I’ve not thought much on that compare.
February 24th, 2011 at 1:38 pm
Paul,
This is exactly the scenario I’m actually TRYING to do.
See we have a site that has press releases related to products, and then images of the products. We are tagging the press release with the product name (which thus creates a ‘post tag’), and then we are tagging the image with the same product name (thus creating a ‘media tag’). Obviously WP doesn’t allow 2 tags with the same slug, so it appends the slug with ‘-#’ on the second tag created. Given the fact that there are no guarantees as to which will come first (‘post tag’ or ‘media tag’) I can’t guarantee logic to strip out the ‘-#’ to run a proper comparison search. Perhaps another option would be to allow for a ‘%LIKE%’ search, instead of ‘IS’ so that similar tag slugs would work? However, this also could create problems b/c we have very similarly named products. We are currently looking into NOT sanitizing the slug name to allow us to search on ‘name’. Any suggestions from your side would be greatly appreciated though. When we complete this I’d be happy to shoot you our code to show you what we came up with.
Thanks
J
February 24th, 2011 at 1:59 pm
Paul,
Just an FYI, we got it working as needed with a little hacking of your code!
Here’s what we ended up doing in the ‘media_tags.php’ file (starting ln191)
if ($r['search_by'] == “name”) {
if ($r['media_tags_array'])
{
foreach($r['media_tags_array'] as $idx => $val)
{
$r['media_tags_array'][$idx] = $val;
}
}
// Next split the comma-seperated media-types list into an array
if ($r['media_types'])
{
$r['media_types_array'] = split(‘,’, $r['media_types']);
if ($r['media_types_array'])
{
foreach($r['media_types_array'] as $idx => $val)
{
$r['media_types_array'][$idx] = $val;
}
}
}
} else {
if ($r['media_tags_array'])
{
foreach($r['media_tags_array'] as $idx => $val)
{
$r['media_tags_array'][$idx] = sanitize_title_with_dashes($val);
}
}
// Next split the comma-seperated media-types list into an array
if ($r['media_types'])
{
$r['media_types_array'] = split(‘,’, $r['media_types']);
if ($r['media_types_array'])
{
foreach($r['media_types_array'] as $idx => $val)
{
$r['media_types_array'][$idx] = sanitize_title_with_dashes($val);
}
}
}
}
So far, it seems to pass all our tests and is kicking out appropriate images related to our post tags.
Next we are moving on to adding the ability to do a one-to-many return, so that if a post contains multiple tags (for multiple products mentioned), we can return all related images with those media tags. Thoughts?
February 24th, 2011 at 2:13 pm
@Justin: No comment needed. I think you are doing well with the code on your own.
February 24th, 2011 at 9:16 pm
Glad that you were able to reproduce and address.
A suggestion…I’d like to filter in the media gallery for items that have no tags rather than a specific tag.
Regards!
February 25th, 2011 at 6:22 am
@Tom: Thanks for the new comment. Yeah about to update Media-Tags with the fix as well as some other bugs closed out.
The filtering by no tags seems to be a common request. So guessing that will be next after this bug fix release. Basically there was a bunch of logic in the original 3.1 release candidate series where I modified Media-Tags. Seems at the last minute WP was change to excluded this functionality. So no new features in this version.
March 1st, 2011 at 11:49 am
Is there a way I can use this with a custom taxonomy I already created? For example, I want to upload audio and tag it with the list of bands I already have in my “bands” taxonomy. A simple interface like the one on the posts pages is all i need. I’m willing to compensate you for your time.
March 1st, 2011 at 12:01 pm
@Rich Gilberto: There is not a way for you to use the specific code in the Media-Tags plugin but that code is standard WordPress actions/filters. Take a look into mediatags_admin.php
There are two standard action line 11-12 in mediatags_admin.php
add_filter( ‘attachment_fields_to_edit’, ‘mediatags_show_fields_to_edit’, 11, 2 );
add_filter( ‘attachment_fields_to_save’, ‘meditags_process_attachment_fields_to_save’, 11, 2 );
These get called when an attachment is loaded or saved. And the nice thing is these functions are the same if you edit a Media item in the Media > Library or via the media popup on the post edit form. Just trace through these and you will be able to steal whatever code you need to make it work with your own Taxonomy.
March 3rd, 2011 at 12:43 am
I am trying to move a very large WP site to a new domain and I’m using the WP import/export XML function.
However when importing all of the media tags “Failed to import ”
Any ideas? All pages, posts etc. import fine.
March 7th, 2011 at 9:10 am
Hi Paul,
Have some problems concerning speed when retrieving media by their media tags.
Can take up to 2,5secs for only one picture!
An example argument for the get_attachments_by_media_tags function would be:
“media_tags=911_coupe_ss_1986,home&tags_compare=AND&size=thumbnail&search_by=slug”
I’m only retrieving one picture per call with this. It has somewhat a random execution time to it.
If you like, I’ll get you more information on it and the site I’m working on…
It’s really a nasty issue and seems to be related to the media tag functionality. Slows down the site to response times of nearly a minute!
Please, need some help!
March 7th, 2011 at 9:33 am
@David: Yeah that old compare code is well old. It has to query for each media_tag term you are searching for. But this is supposed to be indexed. So doing the lookup for each searched term should be fairly quick. I’ll double check the code. On the other hand are you running WP 3.1? With 3.1 they streamlines the query of multiple terms. So you could for example do your own query and not need to call the Media Tags function.
March 7th, 2011 at 11:34 am
Not to pester anyone, but I left a comment earlier regarding the same issue and I think it got overlooked.
Can I use get_attachments_by_media_tags to display a list of images, and link each image displayed to the archive page for that media tag?
Also, I upgraded WordPress and Media Tags about a week ago and encountered a custom taxonomy problem. Custom permalinks no longer worked – until I selected the “Month and Name” permalink option, then switched back to “Custom”. Selecting another permalink option provided in WordPress, and then switching to “Custom” didn’t resolve the issue. So it seems like either I needed to select a couple options before switching to “Custom”, or there’s something special about “Month and Name”. Not sure if that’s an issue anyone else has run into, but I figured I’d bring it up.
Thanks!
March 7th, 2011 at 12:30 pm
@Chris: Sorry to have missed your initial comment.
Yes, you can use get_attachments_by_media_tags to list images in format you desire. Look into the callback function parameter. You basically want to setup your own function which will build the HTML code for each image found. This can be a list item element or whatever. Since are building this function yourself you can link the image to an archive page. Look at the file mediatags_shortcodes.php at the bottom for examples of callback functions. Warning: Copy these and give your function a unique name. Otherwise there will be issues if/when you upgrade next time.
As for your issue on Permalink this had not been reported before. What version of WordPress are you running? What other plugins are you running which may create their own rewrite rules. For Media-Tags in the code I simply call register_taxonomy with the parameters to set this up in WordPress. No hacks or anything.
Let me know it you have any other issues.
Thanks.
March 12th, 2011 at 4:29 pm
hey paul,
can you please responde to my question that i posted on the 9th of february, you may have missed it, i dont know. it would be good to know that it is possible at all what i would like to do, thanks, i just copy my original question here:
thanks for the plugin, its cool and very helpful!
i know nothing about programing and just cant get the media tag cloud work. basically i would like my photos to be pulled by media tags through the cloud and displayed in gallery using cleaner gallery+lightbox script.
can you please explain this in a very simple way?
thank you!
steve
March 14th, 2011 at 1:37 pm
steve,
Sure. I’m not sure I follow your question. Media-Tag does support a tag cloud but does not pull image from the ‘cloud’ or a content delivery network like Amazon S3. All the images need to reside within WordPress. Though there are some plugins out there which will push your uploaded media files to external networks.
March 15th, 2011 at 4:47 pm
thanks paul,
no, i was thinking about something else, i make an attempt to explain, my english is not very good, but ill try.
first, i would like to tag not only my posts on my wordpress site, but the individual images as well with different tags. i nelieve this is what media-tag is for.
then, i would like to have a tag cloud, in which the tags are not the ones that wordpress provides by default (you know, words that posts are tagged with) but tags that i have tagged my pictures with by the help of media-tag plugin.
so, i would have the ‘categories’ widget with the categories that i add my posts to, plus, i would have a tag cloud displaying tags that i add to my pictures separately with media-tag plugin.
then, once clicked on tags in the tag-cloud, i would like the visitors to be taken to a page where they would see all the pictures tagged with the one they have chosen from the cloud in a gallery (which i would use the ‘cleaner gallery’ and ‘lightbox script’ for.
i hope this makes more sense
thanks paul.
March 15th, 2011 at 4:58 pm
paul, i basically would like to have what these lines suggest, but i have no idea how to do it:
“The Media-Tags plugin also supports a wide range is available template function you can use in your theme templates. For example to list out the Media-Tags tag cloud which is very similar to the Post tags tag cloud you would add the following to your sidebar.php
mediatags_cloud(); “
March 17th, 2011 at 7:12 am
$media_items = get_attachments_by_media_tags(‘media_tags=vacation,hawaii&numberposts=10&return_type=li’);
if ($media_items) {
echo “”. $media_items. “”;
}
display nothing for me … simply an array.
March 20th, 2011 at 6:19 am
Hi Paul,
thanks a lot for your plugin. I’m using it collaborating with the tag-gallery which is allso very nice…
I implemented the “tag-team” in several sites working great.
this weekend i tried it on my own site http://www.tradesign.de but there is a problem. the tag-gallery wont show up. I checked the roles. The media-tags roles manager says that there are no users at the administrator level. In fact there aren’t any users listed.
I’m running wp 3.1 and tested with absolutely no plugins except for tag-gallery, media-tags and cleaner-gallery.
Can you help me?
March 20th, 2011 at 9:03 am
Solved!
It was a permalink issue…
Sorry!
March 23rd, 2011 at 4:34 am
Paul,
Great plugin. I’m using it heavily on a site I’m building out for a client, along with Tag Gallery.
I’m wondering if you’ve used the shortcodes in conjunction with any audio&video players. Considering writing a function to generate a list of mp3s, or a list of videos, all with inline players.
March 23rd, 2011 at 7:02 am
Harry » I have not personally but I know from other users they have used Media-Tags with other gallery slideshow and even things like Gravity Forms. The hooks for doing this will be within the shortcode parameter ‘display_item_callback’. Take a look at the file mediatags_shortcodes.php. At the bottom are two function which are examples of using the ‘display_item_callback’ shortcode parameter.
March 23rd, 2011 at 11:45 pm
Paul – thanks for the direction, I’ll check it out.
March 24th, 2011 at 1:58 am
[...] noch nicht angegeben hatte, und bei noch vielen mehr fehlen die mediatags. Den Sinn der Mediatags habe ich gelegentlich schon angesprochen und werde in den nächsten Wochen dem Thema einen eigenen [...]
April 1st, 2011 at 2:22 pm
Hi there,
Noticed that in WordPress 3.1 the media_tagcloud() function needs some changes.
This seems to work:
function mediatags_cloud( $args=” ) {
if (function_exists(‘wp_tag_cloud’))
{
$defaults = array(
‘taxonomy’ => MEDIA_TAGS_TAXONOMY
);
$r = wp_parse_args( $args, $defaults );
//return wp_tag_cloud( $r );
return wp_tag_cloud( $defaults, $args );
}
}
Hope this is helpful for people getting the “First argument is expected to be a valid callback” PHP error.
April 1st, 2011 at 3:00 pm
Katie »
Thanks for the comment but I’m confused. According to http://codex.wordpress.org/Function_Reference/wp_tag_cloud an the actual wp_tag_cloud function it only take one argument. In your code suggestion you are passing two arguments defaults and args. In PHP you can pass extra arguments but ths receiving function ignores then. Wondering if you have a plugin that has offered its own wp_tag_cloud function.
April 1st, 2011 at 3:01 pm
Building on my last comment:
Oops: I meant to write mediatags_cloud(), not media_tagcloud().
I don’t think this is an issue with the Media Tags plugin … I’ve been troubleshooting the problem and it seems to be with the use of call_user_func() in wp_generate_tag_cloud() — so a WordPress 3.1 issue.
This isn’t a stellar solution, but I’ve found replacing line 681 in wp-includes/category-template.php with the below line works:
$a[] = “<a href='$tag_link' class='tag-link-$tag_id' title='" . esc_attr( $tag_name . " " . "(" . $real_count . ")" ) . "' style='font-size: " .
p.s. You can also undo the changes I suggested in my previous post.
p.p.s. Media Tags is fantastic!
April 1st, 2011 at 3:03 pm
Katie » Thanks for the awesome followup. You rock!
April 1st, 2011 at 8:56 pm
Another little issue, this time with the Media Tags plugin itself:
In mediatags_template_functions.php, line 161, we have this:
return apply_filters( ‘get_the_mediatags’, get_the_terms( $id, MEDIA_TAGS_TAXONOMY ) );
The apostrophes are causing issues. This works for me:
return apply_filters( ‘get_the_mediatags’, get_the_terms( $id, MEDIA_TAGS_TAXONOMY ) );
April 1st, 2011 at 8:57 pm
Alright, they look the same on here. But in a text editor you’ll see the difference.
April 5th, 2011 at 10:26 am
The media-tags option is no longer available for me through the library drop-down list. I’ve running 3.0.3 media tags, and 3.1 WordPress.
I only noticed this last night, but I haven’t tried to use it since upgrading to wordpress 3.1. I also upgraded to Media-tags 3.03 at about the same time…so I can’t say for sure which upgrade may have caused the failure.
April 5th, 2011 at 10:29 am
TomH » Thanks for the comment. Try reactivating Media-Tags from the Plugins panel. HAve had reports from others after running the WP automated upgrade they experience similar issues. The reactivation usually fixed the issue.
April 5th, 2011 at 11:22 am
@Paul: Sorry, I should have listed my corrective action attempts, thus far:
1. Turned the bulk-edit function off, and back on for both library and media-panel, in all possible combinations (together and separately).
2. Deactivated/reactivated the plugin.
3. disabled the bulk-edit options, deactivated, reactivated, re-enabled the bulk-edit options.
4. Deactivate plugin, logout, login, reactivate (both with deselecting bulk-edit options and not).
5. Logging in as Admin, rather than just a member of the administrators group.
I have considered, but have not yet:
1. uninstall/reinstall 3.0.3.
2. Upgrading to 3.0.4.
3. Remove related plugins one by one to isolate potential side-effects…don’t want to do this, painful.
4. Upgrade to WP 3.1.1.
3.
April 6th, 2011 at 6:56 am
TomH » If you log in as the default admin account. Or whatever your default user when you installed WP. Under the Media-Tags settings check the Role Permissions for users. Also are you running normal WP or Multi-Site?
April 6th, 2011 at 8:33 am
@Paul: “No users at this level” for ALL levels from Admin through subscriber.
I don’t seem to have any ability to edit this page. I can’t find any buttons / controls to change / add users to any of the roles.
Normal WP 3.1.
April 8th, 2011 at 11:32 pm
Nice plugin Thanks for posting such a Thing…
April 9th, 2011 at 9:43 am
I am getting a 404 error when I try to access /media-tags/slug.
WP version 3.1
Media Tags v 3.0.4
I have tried all sorts of different templates. Any help much appreciated.
April 9th, 2011 at 9:46 am
Ulysses Oliver »
Things to try.
1. First deactivate the Media-Tags plugin then reactivate it. Test your URL.
2. If still issue try updating your Permalinks. Also, I had some users report that they needed to change the permalinks to something else. Then change it back.
Something with the way WP handles the updates. I’m sure it is a bug on the Media-Tags registration logic.
April 9th, 2011 at 8:34 pm
Thank you very much for the quick reply Paul. I had tried what you suggested with no luck. I have now got to the bottom of it however! I had a custom permalink structure of /%post_name%/ which I guess was causing a conflict with media-tags. I have changed the permalink to use ‘month and name’ and it all works. Thanks you so much for this plugin!! Love it
April 10th, 2011 at 9:24 am
@Paul-
I updated to 3.0.4 (reapplying the few customizations I’ve made) and all is well.
Nothing else worked, but its all good now.
-tch
April 12th, 2011 at 8:32 am
Paul – thanks for a great plugin!
There’s a bug (version 3.0.4) which stops the roles/capabilities part of the plugin working if you have a custom table prefix (ie something other than wp_).
This should fix it:-
@@ -387,7 +387,9 @@ function mediatags_roles_panel()
}
else
{
- $user_capabilities = $user->wp_capabilities;
+ global $table_prefix;
+ $capabilities_key = $table_prefix . ‘capabilities’;
+ $user_capabilities = $user->$capabilities_key;
}
if (isset($user_capabilities))
mark.
April 12th, 2011 at 8:12 pm
Mark Rowatt Anderson » Ah. Thanks for that excellent bug find. I’ll fix for the next release.
April 20th, 2011 at 7:22 am
you’ve probably already answered this question, but I can not do what I want. I have a page style (mediacat.php) This file is part of my template. I insert the equivalent of [media-tags media_tags = "example?"] in my php page?
I try this:
It works but not for all tags. Those with space does not work, eg “new york”.
Someone a solution?
April 20th, 2011 at 7:23 am
I try this:
$voyage = $_GET['voyage'];
$mediaTags = get_attachments_by_media_tags(‘media_tags=’.$voyage.’&return_type=li’);
echo $voyage;
echo $mediaTags;
April 20th, 2011 at 7:37 am
I think I have an idea for my problem, but, How to get the name for the url (New York becomes: new-york)
April 21st, 2011 at 7:13 am
I succeeded by using the variable: $media_tag_item-> slug. But it only works on mediatags_template_functions.php, how to use this variable on another file?
April 27th, 2011 at 2:55 pm
I’m using the simple script below. As long as I specify return_type=li it works fine. However, I need to use the raw image code (not wrapped in li tags) but whenever I remove return_type=li something breaks. When the page is parsed, I get only a piece of code that says “Array”. Any idea why this might be happening?
$current = $post->ID;
$media_items = get_attachments_by_media_tags(‘media_tags=top&size=full&post_parent=’.$current.’&return_type=li’);
if ($media_items) {
echo $media_items;
}
April 27th, 2011 at 3:09 pm
Mike »
Thanks for the comment and thanks for using my plugin. Your function setup looks correct and the fact that the function is returning an array tells me the return information is correct. When not using the return_type=li you will be returned a raw array of attachment object. This is not just the image link or image URL. This is the raw items used within WordPress. So in other words you cannot just echo the return array or objects.
Not sure on PHP knowledge but you will want to setup a foreach loop construct. Like the example below. Within the loop you want to call one of the many WP functions to display the actual image_item. Like http://codex.wordpress.org/Function_Reference/wp_get_attachment_image
foreach($media_items as $media_item) {
// Now within the loop you will need to ‘process’ each media_item.
echo wp_get_attachment_image($media_item->ID, ‘thumbnail’);
}
April 27th, 2011 at 4:43 pm
[...] with nice bells and whistles, but don’t recognize my already exiting media tags via “Media Tags“. And I tested “th23 Media Library Extension” and “shuffle” … [...]
May 7th, 2011 at 12:57 pm
hi,
Great plugin, simple idea but very useful. I am trying to set up a custome page that calls all the images with the same tag as the page name. tried using the code you used above but get an error
code:
post_name.’&return_type=li’);
>post_name.exemple&return_type=li’);
if ($media_items) {
echo “”. $media_items. “”;
}
?>
Error:
Parse error: syntax error, unexpected ‘=’ in /home/baciata/public_html/wp-content/themes/twentyten/blogproduct.php on line 15
Do you know where I am going wrong?
May 8th, 2011 at 4:05 am
Thats odd that should have come out as
$media_items (get_attachments_by_media_tags(’media_tags=’.$post->post_name.’&return_type=li’));
>post_name.exemple&return_type=li’);
if ($media_items) {
echo “”. $media_items. “”;
}
May 10th, 2011 at 10:23 am
On 1/25/11 you and Pat Cavit talked about making the media-tags hierarchical. Let me second that request. I have dozens of family genealogy images that I would like to tag by Person, by Place, and by type (e.g., birth certificate, census, photo, news clipping, etc.). Hierarchical media-tags, similar to categories or custom taxonomies would be great! Thanks for all your good work.
May 24th, 2011 at 9:09 am
Paul
I’d love some help on dealing with Media Tags role management. I have some networks with multiple hundred sites, and since upgrading to a version with role management, I’ve gotten some weird behavior.
On one network, nothing has really seemed to change.
On another network, nobody can add media tags anymore! I really don’t want to go back through manually and give everyone permission…
Is there any good documentation about the change that was made, or ways to make this role feature more scalable/managable?
Feel free to email me directly (I lost your email).
(Ideally, all Administrators on all sites could Manage Settings and Tags. All Authors+ could be able to assign tags.)
Thanks!
May 25th, 2011 at 6:08 am
Using the php mediatags_cloud() within a text widget, I am finding the results to be missing the image. The link to the image is there, the placeholder for the image is there, but the resulting images are missing. Upon reviewing the source, the img src= tag has no value for any of the returns. Is there a simple solution? Has anyone run into this?
Thanks!
May 26th, 2011 at 12:36 pm
Odiousfunk » Well the media-tags tag cloud is not supposed to show the actual images. It’s a tag cloud much like the WP Post tag cloud. It is to show the ‘tags’ themselves.
May 28th, 2011 at 7:55 am
[...] Provides ability to tag media/attachments via Media Management screens Version 3.0.4 | By Paul Menard | Visit plugin site [...]
June 4th, 2011 at 7:17 pm
Hi! Thanks for your plugin, it’s very useful, simple to operate, well thought-out.
I’m not too much of a slouch with WordPress (still I’m an amateur coder) but I can’t get the mediatag.php archive to show up.
Whenever I click on a media-tag keyword link, WP takes me to the 404 page. What’s wrong? I’m using WP 3.1.3.
Please help! — Rico
June 5th, 2011 at 11:41 am
Rico »
I’ve not seen any issues with WordPress 3.1.3. But some notes on conflicts with Media-Tags custom rewrite logic. If you have setup a Media-Tags term with the same slug as a Page, Post, Category, Post Tags etc. then you will have an issues accessing the Media-Tags term for some reason. Still have not worked out this logic. For example if you upload some images and tag them ‘Flags’ which will result in the slug ‘flags’ you should be able to access the term archive by the URL http://www.somesite.com/media-tags/flags/ But if you have a Page also titled ‘Flags’ with a slug of ‘flags’ WordPress for some reason will attempt to direct you to that page instead of the Media-Tags archive.
June 5th, 2011 at 7:44 pm
Hi, thanks for your quick answer.
I tried everything I could think of, reverted to 3.1.2, strated from a blank database, have no conflicting slug or post name. In fact I have no regular tag or category defined. I tried with regular posts (containing a gallery shortcode) and new gallery type posts.
Something funny, WP still names my attachment files by their old name, which I changed while importing the files. I think WP uses some ‘title’ or ‘object name’ field from the EXIF (my attachments are photos processed in Aperture and Lightroom). But this name WP is using in the URLs, I don’t even see in the Media Library, so I con’t access it.
Also another thing I noticed was if I create a Media Tag that contains accents (like Montréal), the slug created will also have the accent. This is bad right?
OK, nuff for today. Thanks for your help! Hope you can solve this!
Rico
June 6th, 2011 at 10:24 am
Hi Paul,
Thanks for the work you’ve done on this very useful plugin.
While experimenting with Media-Tags 3.0, I found that I was unable to remove previously assigned media tags via the bulk-admin interface. After a little searching, I found a typo in line 99 of the file mediatags_bulk_admin.php:
Currently:
else if ($media_tags_action == “media_tags_assign”)
Should be:
else if ($media_tags_action == “media_tags_remove”)
After making that edit everything seems to be functioning properly.
Thanks again for your work on this plugin!
Regards, Mark
June 6th, 2011 at 10:52 am
Hi Mark
I suppose you are at work, but I just could let this thing go! I want to see the thing online…
So I noticed my permalinks in my home page for some reason I don’t get, link directly to the posts’ attachment, instead of the post. So on Media-Tags options, I put the Archive Template Display option to ‘No’, and now everything works as intended.
I am happy but I would very much like to understand what happened! Where does that redirect to attachment happen? Please help!!
Rico
June 13th, 2011 at 7:21 pm
Hi
Could you indicate how to get a list of the media tags for a given post in php? I need this to add the media tags to my meta keywords, in the WordPress header.
Thanks
June 14th, 2011 at 2:33 pm
I couldn’t figure out how to extract the names from the array; but nevermind.
Here’s a function to list the post categories and media-tags, without the links (for use in page meta keywords, for example):
// Retrieves categories and media tags list, for meta keywords.
function mtl_get_tags() {
global $post; $post_id = $post->ID;
if (is_attachment()) { $post_id = $post->post_parent; }
$post_categories = wp_get_post_categories($post_id);
$cats = array();
foreach($post_categories as $c){
$cat = get_category( $c );
$cats[] = array( ‘name’ => $cat->name, ‘slug’ => $cat->slug );
$cat_list .= “,{$cat->name}”;
}
$tags = mediatags_get_post_mediatags($post_id);
foreach ($tags as $tag){
$tag_list .= “,{$tag->name}”;
}
$html .= $cat_list.$tag_list;
return $html;
}
Thanks for your help
June 14th, 2011 at 2:39 pm
Sorry, take this one:
// Retrieves categories and media tags list, for meta keywords.
function mtl_get_tags() {
global $post; $post_id = $post->ID;
$tags = mediatags_get_post_mediatags($post_id);
foreach ($tags as $tag){
$tag_list .= “,{$tag->name}”;
}
if (is_attachment()) { $post_id = $post->post_parent; }
$post_categories = wp_get_post_categories($post_id);
$cats = array();
foreach($post_categories as $c){
$cat = get_category( $c );
$cats[] = array( ‘name’ => $cat->name, ‘slug’ => $cat->slug );
$cat_list .= “,{$cat->name}”;
}
$html .= $cat_list.$tag_list;
return $html;
}
June 14th, 2011 at 3:09 pm
Hi, Paul,
As I mentioned in my post on May 23 , I am looking for a way to get hierarchical functionality within Media-Tags. Ideally, I would like to be able to create multiple media tag taxonomies, just as I create multiple custom taxonomies for posts, pages, etc. In my case I would like to have media-tags for People, Places, and Memorabilia Types. In lieu of that capability, I have been using a prefix with each of my media-tags: “pe_” for People, “pl_” for Places, and “me_” for Memorabilia. Hopefully, when I use the function “get_attachments_by_media_tags()”, I will be able in some way to extract, for example, all the People tags and display a list containing only the media-tags starting with “pe_” (e.g., pe_Tom, pe_Dick, pe_Harry). I am not a PHP expert, so can you suggest a way for me to extract only such a subset of tags? I really appreciate your terrific plugin, and I am looking forward to using it on my genealogy website. Thanks.
June 15th, 2011 at 8:36 am
Rico » Thanks for sharing the code. Sorry for not replying earlier. I’ve been traveling for the past few weeks.
June 15th, 2011 at 8:42 am
Bob T » I like the concept but there are some issues. Media-Tags is just a Taxonomy itself associated with the ‘attachment’ post_type. So no way to create sub-taxonomies. Technically I could setup the taxonomy to be like categories, which are hierarchical, instead of post tags which are not. But then that changes the actually tagging interface used on the media library.
Let me think how to do this. I might be able to do some optional logic to handle display of the tag categories. But it will be after this month. I’m in the final stages of a big project finally closing the loop on my development commitments.
June 15th, 2011 at 9:08 am
Mark Esterly » Thanks for investigating and providing the correct code. I’ll be sure to include this in the upcoming release.
June 15th, 2011 at 3:19 pm
Thanks, Paul. Would it be possible to create a second (third, fourth,…) taxonomy just like Media-Tags (e.g., Media-Tags-2) that could also be associated with the “attachment” post type. This appears to be possible with the register_taxonomy($taxonomy, $object_type, $args) function by setting $object_type to “attachment”, but there would need to be modifications in the UI of your Media-Tags plugin to allow multiple media-tag taxonomies. The Media Library Editor and “Add New” UI would also have to allow multiple media-tag taxonomies to be associated with a single attachment. The more I write, the harder it sounds, but I hope you will see it as a worthwhile challenge. Thanks for taking time to respond. I look forward to hearing your thoughts.
June 15th, 2011 at 5:36 pm
Bob T » Well yes, of course you can register other taxonomies using the WP function. That is the easy part. But unlike custom taxonomies like you would setup for Post, Pages of other custom post types, WP doesn’t provide any automatic support for the taxonomy for attachments. So that is why I have all the supporting code for Media-Tags.
The better an easier option would be just to make the current Media-Tags taxonomy work like categories and support children. But still that is complicated since my who interface will need to be changed. Again, not an easy task. And I need to concentrate on closing out a big project by end of the month then I can concentrate on changes to the Madia-Tags plugin code.
June 15th, 2011 at 11:03 pm
Hi, Paul,
Good luck on finishing your big project. I’ll look forward to hearing from you again about the Media-Tags plugin sometime after the end of the month.
Your idea to adapt Media-Tags taxonomy to work like hierarchical categories does sound like the best way to go. I trust you will come up with some good ideas about how to do it.
June 16th, 2011 at 8:56 am
Hi Paul, thanks for your reply.
if somebody wants to use media-tags as meta keywords (for SEO), use the function posted above (which goes in functions.php) and put this in your header:
<meta name="keywords" content="” />
Your plugin is great cuz it allows me to use attachments as posts (it’s a collection of photos) with some galleries. But, attachments don’t get listed in the WP Google xml Sitemap plugin, do they? Something I’m missing?
Thanks
PS: I dunno if you saw above, when you get the time to check out the accents issue, happens when creating the media-tag (they’re not stripped from the slug).
June 16th, 2011 at 1:04 pm
Rico » Thanks again for all your comments and how to information. I had included the Title function sometime again. Glad to see others are thinking SEO information. I had not seen your comment on the accents. Will try and run down that part of the code soon and get a new release of the plugin out. I have a list of other minor bugs to patch.
Also, do I have permission to use your code as part of the plugin’s template functions?
June 16th, 2011 at 8:20 pm
Of course, please use it, part of it is from the WP Codex anyways
I messed up my “tutorial” above by putting plain php in my answer — sorry: the php code that goes in the WP header should read
.
As for the sitemap thing, the Google Sitemaps plugin can be extended quite easily it seems (to include attachments). If i ever figure it out I’ll post here
See ya! Keep on the good work
June 18th, 2011 at 11:46 am
Hi, many thanks for the plugin and support. I had the same question as #203 (I couldn’t find an answer). I am using list_mediatags to output all years entered for artwork attachments but would like the results page to give the clicked on search term a “current-item” class the same way wp_list_pages does and make it feel part of the menu. Something like this:
Sidenav:
wp_list_pages (one parent and children):
Work > painting
> > painting subject 1
> > painting subject 2
> photography
> > photgraphy subject 1
> > photography subject 2 etc
list_mediatags:
Work by year
> 2011 (mediatag1)
> 2010 (mediatag2)
> 2009 (mediatag3) etc
At the moment it causes my wp_list_pages topnav to declare my blog page as “current_page_parent”, which is not appropriate in my setup and not where any of the attachments are from. Would there be any way to create a function so that the results page sees itself as a child of the parent “work” pages/galleries which the media attachments belong to? And beyond that, could list_mediatags also be filtered depending on the top level section from which it is being called, eg if “painting” and “photogrpahy” were both top level items? Hope that makes some sort of sense and sorry if my level is too basic! Cheers, Zach.
June 21st, 2011 at 8:30 am
Media Tags ” CodeHooligans…
[...]Media-Tags 3.0 Released I’m proud to say I’ve finally released Media-Tags 3.0 to the general public and is available in the WordPress plugin reposito[...]…
June 22nd, 2011 at 9:12 am
Does not work with WP 3.1.3 and User Role Manager. Roles in Role management plugin section are empty even if checked in User Role manager. Shortcodes does not work.
June 23rd, 2011 at 12:23 am
Hello! Thanks for your great plugin.
I wanted to know if there is a way to exclude an array of posts in the get_attachments_by_media_tags() function.
I ask this because I show two tags gallery on my page with two sets of diferrent sets of keyword, but I don’t want to get any images repeated in the last gallery… so I would like to save the attachment ID of the first gallery in an array (this part is not a problem), then exclude that array of attachment in the second gallery (this is where is the problem, since I didn’t find any way to exclude some attachment posts)..
Sorry if it seems confused, english isn’t my native language.
Thanks for your help!
Dave
June 24th, 2011 at 7:17 am
Dave » Thanks for the comment. Sad to say there is not a direct way to exclude attachments via the get_attachments_by_media_tags() function. I will investigate adding an ‘exclude’ parameter. You should be able to accomplish this with some array compare logic.
July 1st, 2011 at 12:45 pm
Hi Paul, Greate plug-in. I’ve been using it for for a bit without any problems when using the shortcode. I’m now trying to work it into my template and am running into some errors. I’m somewhat new with wordPress and am more of a designer than a programmer, so maybe the solution is simple but I’m just not seeing it. The code I’m using is below, but I get the error message: “nvalid argument supplied for foreach()”
ID;
$media_items = get_attachments_by_media_tags(‘media_tags=top&size=full&post_parent=’.$current.’&return_type=li’);
if ($media_items) {
foreach($media_items as $media_item) {
// Do some stuff
}
}
?>
July 2nd, 2011 at 11:52 am
Jon Michael » Thanks for the comment. Question related to your example. What is the value of ‘$current’. This should be an ID not an object. so thinking you might need to pass $current->ID or something. I’ll check media-tags against the latest WP version soon.
July 6th, 2011 at 9:36 pm
hi paul , why can’t working in my template like this:
$media_items = get_attachments_by_media_tags(‘media_tags=top&return_type=li’);
if ($media_items) {
foreach($media_items as $media_item) {
echo ‘‘.$post_item->post_title.’‘
}
}
July 8th, 2011 at 7:05 am
Hello Paul,
Please have a look at the WP support forum when possible. There are many bug-fixes for your consideration for the next update.
Cheers.
July 8th, 2011 at 9:12 am
@Paul I am getting this error when trying to use get_attachments_by_media_tags:
Warning: implode() [function.implode]: Invalid arguments passed in /home/user/domain.com/wp-content/plugins/media-tags/media_tags.php on line 291
I have tried forcing $array_unique_ids to an array and tried adding @ in front of implode to suppress the error but I get no results. Here is the code I am using:
$att = get_attachments_by_media_tags(‘media_tags=scroller&post_parent=12′);
I have several images in the scroller tag under that ppost so it should return results but it is not. Please help I will be eternally grateful it is kind of urgent to finish a project I am at the end of my ropes with.
July 8th, 2011 at 9:22 am
@Paul also when I print_r $array_unique_ids just above the if statement with the implode I get this:
WP_Error Object
(
[errors] => Array
(
[invalid_taxonomy] => Array
(
[0] => Invalid Taxonomy
)
)
[error_data] => Array
(
)
)
Which I gather means something further up is going wrong.
July 9th, 2011 at 8:42 am
alx359 » Thanks for the comment. I will review the WP support posts soon. Have been away on holiday.
July 9th, 2011 at 8:45 am
DigitalFiz » Sorry for the delay. I was away on holiday all of last week. Are you still having an issue? Did you find a solution?
Try leaving off the ‘post_parent’ option. The result returned will be an array of posts. You can loop through these and remove the items that are not post_parent 12.
July 9th, 2011 at 8:46 am
DigitalFiz » I’m not sure what you are showing me here. Are you actually hacking the plugin code??
July 9th, 2011 at 8:50 am
jimmy » You need to check your coding. Inside the foreach you are calling undefined variables like $post_item and $image_src. These are not set by the Media-Tags plugin. My suggestion is to not use the argument ‘return_type’. This will return the result as a PHP array. With the array you can then go into a foreach look for process the results. If you don’t want to code your own foreach then leave the ‘return_type’. In this case the returned result will not be an array. Instead you will receive the HTML li elements as a single string. You can check if the return is empty of not. If not empty just echo the returned variable.
July 9th, 2011 at 9:21 am
DigitalFiz » Just setup a new local instance or WP 3.2. Installed the published version of Media-Tags (3.0.4). Added a new Post (post_id-4). To that post I uploaded 6 images. Of those 6 images I tagged 3 as ‘Scroller’.
As a test in the TwentyEleven theme file footer.php I added these 2 line of code:
$att = get_attachments_by_media_tags(‘media_tags=scroller&post_parent=4′);
echo “att
“;
The output is the three images tagged to the tag. I’m not sure I see the problem. From where are you calling the get_attachments_by_media_tags function? Are you possibly calling the function before the Media-Tags plugin has been initialized by WP?
July 15th, 2011 at 11:41 am
I have a client who has potentially hundreds of PDF files that will be displayed on a page.
I have a couple of questions…
1) is there any way to call the tags to place in a class? like class=”tag1 tag2 tag3″? I have tried several different ways to add it, but I don’t seem to see a function call that just outputs the classes. I’m definitely missing something.
2) Is there any way to query with pagination? I’ve tried applying the tags/custom taxonomies to a standard category query with pagination. I haven’t had any luck. I’m probably not having something labeled correctly.
3) Is there any way we can output the file data size ? ie (14kb, 1.4mb, etct?) I would like to display this variable next to the title in the output.
Thanks again for the great plugin. This seems to be one of the only ones like it, and it seems to be great so far!
July 15th, 2011 at 11:55 am
Jeremy miller » Thanks for the comment.
1. There is not a specific function I’ve provided to do this. But realize that Media-Tags is just a Taxonomy associated with the Attachment post. So closing thing I can suggest is calling the Media-Tags function get_the_mediatags($id) where ID is the post ID. Take a look at some of the functions in the plugin file mediatags_template_functions.php. Most of these have been added over the years by myself and contributors to do things with the media-tags taxonomy. If you come up with something please consider sharing.
2. Depends on how you are doing a query. Again since this is a Taxonomy you can query it directly using various built-in WordPress functions. If you are using the Media-Tags function get_attachments_by_media_tags() is should support an offset parameter. Internal that function calls get_posts with the arguments passed in. Though there might be a hole in the logic for paging.
3. For the output you might want to look into using a custom callback function. As one of the parameters to the function get_attachments_by_media_tags(), you can pass a value for the parameter ‘display_item_callback’. This function will be called for each item found. Check out the example function default_item_callback() in the plugin file mediatags_shortcodes.php. Also, just after that function is another example which displays the caption of the image. These are example. Meaning do not directly modify these in the plugin files. Create your own function in you theme’s functions.php file or somewhere.
Good luck and let me know if you get stuck.
July 15th, 2011 at 1:28 pm
Great. Thanks for the advice. I’ll certainly look into it!
Thanks again for the awesome plugin.
July 27th, 2011 at 10:19 pm
I am suddenly getting a blank screen when calling get_mediatags() with no errors – despite turning errors on. Very weird as it has been working just fine for months now. WP version 3.1. Any thoughts?
July 28th, 2011 at 12:28 am
Issue resolved. The get_mediatags() function crashes wordpress without any errors if you have too many matching items. I increased my WordPress memory allocation and this fixed the problem – after losing half a day! Argh. But I still love this plugin!
July 30th, 2011 at 7:23 am
Hello there,
Wonderful plugin. I would like to output plain text for the tags associated to each image, in a WordPress gallery.
Usually we can access the images metadata with a special call, for example the captions, we would use:
$attachment->post_excerpt
…and the image description would need something like:
$attachment->post_content
…or the image’s title:
$attachment->post_title
, as a way to pull out that kind of metadata for the images.
Could we have a “posts_tags” the same way?
Many thanks for your help,
July 30th, 2011 at 10:37 am
Jan » It depends on how you are requesting the media-tag items. If you are calling the Media-Tags function get_attachments_by_media_tags() this will return an array of items matching your query. By setting up a foreach loop you can call the WordPress function ‘the_terms()’ for each element. See the WordPress Codex for details.
Also, if you are using the ‘display_item_callback’ parameter you can do this in your callback function. Check the file mediatags_shortcodes.php where I’ve provided examples.
Hope this helps.
August 5th, 2011 at 6:56 am
Hey there
Just wanna know how I would get the single tag title from my template not from the archive or mediatags.php.
I’ve tried this single_mediatag_title()
but it doesn’t work from my header.php which is where I need it.
Many thanks in advance!
August 5th, 2011 at 8:40 am
Will » Depends on exactly what you are attempting. If you know the tag slug you can use the built-in WordPress function
get_term_by(); like this:
$mt_term = get_term_by(‘slug’, ‘flags’, MEDIA_TAGS_TAXONOMY); where ‘flags’ is the term slug.
This will return the term object to you ($mt_term). This will contain all the information on the term. To access the name use $mt_term->name
not as clean as calling a simple function.
August 5th, 2011 at 9:15 am
Hey Paul, thanks for your reply and your help
Well I have a list of images that the user uploads, attaches meta data to them and then using javascript, I do a simple search – Hide/Show.
So the search box will be populated dynamically from the list of tags and when the user clicks on one of the dynamically created tags from the drop down, my javascript will look through the thumbs and search for a thumb with a name which is equal to that which is clicke from the drop down. It will hide all that are not similar.
So if I have a list of images that are in the same category, all of these will remain shown.
This is the html/PHP that I use to simply create each thumb and as you can see, I want the name of each thumb to have the associated tag in it which will correspond to the list of tags outputted in the header.
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
query_posts('category_name=work&showposts=100');
$mt_term = get_term_by('slug', 'financial-services', MEDIA_TAGS_TAXONOMY);
?>
<?php while (have_posts()) : the_post(); ?>
<li class="thumb" name="<?php echo $mt_term->name; ?>" rel="<?php the_post_thumbnail_caption(); ?>">
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
<?php the_post_thumbnail(); ?>
</a>
<h4><?php the_title(); ?></h4>
<?php the_post_thumbnail_title(); ?>
</li>
<?php endwhile;?>
</ul>
Simply in the header, I use:
2
3
4
5
<?php list_mediatags(); ?>
</ul>
Thanks for your help, hope I got the
wrapper right, lets see! : )
August 5th, 2011 at 9:18 am
Oh I forgot to change the code.
See where it says:
Where i’ve put ‘CONTEXTUAL TO EACH IMAGE’ is where it should be specific to the image in the loop.
Does that make sense?
Thanks again!
August 16th, 2011 at 11:26 pm
Great plugin, it’s been very useful to us so far. I have noticed one bug in mediatags_admin.php line 360. If any of these roles don’t exist the plugin errors and wordpress deactivates it. It might be worth adding a check for if the role exists around each add_cap.
August 17th, 2011 at 4:03 am
[...] course I could always just sit down and write my own gallery code based on the tags from the Media Tags [...]
August 17th, 2011 at 6:59 am
Jack » Thanks for the comment. I’ll investigate that bug. Thanks.
August 24th, 2011 at 8:40 am
Your plugin looks perfect! I plan to use media-tags to tag a photo collection, perhaps 300 images (say 40 tags). I’m going to use tag-gallery for most of the pages that I plan, but I also want to create a simple random slideshow (for sidebar use) of selected tags. Can you recommend any plugins that would work nicely with media-tags?
August 29th, 2011 at 10:26 am
Having trouble with shortcode.
Displays bulleted list on page but not returning media title/link. What am I missing?
Using this shortcode:
[media-tags media_tags="newsletter"]
September 1st, 2011 at 8:12 am
About Translation.
i found the lang/media-tags.pot file and made a new media-tags-es.pot using Poedit.
what is next? where do i insert the new file? how do i name it?
very good plugin
September 1st, 2011 at 1:40 pm
oes » This is great. I don’t know that you can upload this to wordpress.org. Since I manage the plugin you need to pass it to me then I’ll include it as part of the plugin package. I’m assuming you have tested this on you own WordPress site and everything works correctly for the translation.
September 5th, 2011 at 8:03 pm
First, amazing plugin! Question: is there a way to show the title and description associated with the image? I’m trying to create a slideshow that also displays more details. Thanks in advance for your help
September 6th, 2011 at 5:55 am
Hi – very well done with media-tags – it is a really useful plugin
But I wonder if you could help me because I don’t have your function reference guide. I am trying to mod tag-gallery to display the image tags as a caption on each image. He uses your get_attachments_by_media_tags() function to grab a list of attachments and I just want to use something like get_mediatags() (maybe?) to grab each attachment’s mediatags into an array. But I am not sure what arguments to give get_mediatags() and each time I use it it just returns all the mediatags on file. Can you give me some advice on how to limit get_mediatags() to just the tags for 1 attachment (an element of the array returned by get_attachments_by_media_tags())? Thanks, Chris R.
September 6th, 2011 at 6:08 am
ChrisR » There are a couple of options. Look into the file ‘mediatags_template_functions.php’. There is a function ‘get_the_mediatags’ which take an attachment ID and will return the terns for that item. This an an array. So you will need to build your own loop to display the terms. Another option is to just call the WordPress the_terms() function like this
the_terms( 0, MEDIA_TAGS_TAXONOMY, ”, ‘,’, ‘ ‘ );
The first parameter would be the image ID. If zero is passed it will assume the current global $post.
September 6th, 2011 at 6:48 am
Thanks Paul – that’s superb – I used get_the_mediatags() and passed it the ID field and … bingo! The basic PHP coding is easy enough for me – now I will just work out the CSS and filter out any media-tags that I don’t want to display and it’ll be done
If I feel particularly adventurous I will make it switchable by modding the tag-gallery plugin further
By the way, the Contact page form gives an SMTP authentication error and the link to the Plugin Development book didn’t work when I clicked on it. Thanks again, Chris R.
September 6th, 2011 at 8:28 am
ChrisR » Glad you were able to get this working or at least in a direction. Let me know if you need any more help. And thanks for the note on the contact form. My ISP moved my sites to a new server this past weekend and still some issues.
September 6th, 2011 at 8:43 am
Thanks – it’s always very encouraging when the developer is happy to answer questions
It all seems to be working now – I decided to create a section under the caption where I display the tags dependent on a tag-gallery short-code attribute. Then I added another attribute that allows me to ignore some of the tags so that it doesn’t display the stuff that is strictly meta-data. Anyway, I’ll see how it pans out when I build other galleries that feed off the meta-tag data
September 7th, 2011 at 1:43 pm
Just another quick question (I notice it has been asked before but doesn’t seem to have been answered) … but what are the valid values for the “orderby” argument?
September 7th, 2011 at 1:47 pm
ChrisR » Would be the same and the WordPress core function get_posts http://codex.wordpress.org/Template_Tags/get_posts
September 7th, 2011 at 2:32 pm
Thanks – that fixed my problem