Gallery2:Modules:tags - Gallery Codex
Personal tools


From Gallery Codex

Tags Module

Browse your photos / items by tags. Tag 'cloud'.


Adds a dynamic album view that shows items based on a query on tags. Additional blocks available for different tag presentation; blocks

To view a tagged album, use a URL like:


If the URL Rewrite module is in use, activate the rule for tags to use URLs like:



Tags for an image:

 {g->block type="tags.ImageTags"}

Tag cloud (size limit not implemented):

 {g->block type="tags.TagLinks" sizeLimit=50}

Additional blocks available for better tag presentation; blocks


  • Manage the tags from an admin page
  • Users with Edit Tags permission can
    • Add/remove tags from an item
    • Add "popular tags" to an item
    • Add tags from EXIF info where available (EXIF Module activated needed for that)
  • Tag Cloud (link can be removed)
  • List of Tags in summaries under the items (can be hidden)
  • List of tags for an item in a block (can be placed anywhere)
  • Number of Popular tags viewed can be limited (any number, even 0)
  • New, clean database design. Tags are stored into the gallery2 database using two additional tables, allowing a many-to-many relationship between tags and items (e.g. pictures). This replaces the old keywords that were stored as a single text field for each item and the inherent limitation of this strategy.
  • URL rewrite: /tag/circuit to see a virtual album for items tagged circuit and /tagcloud/ to view the tag cloud, can be configured via the URL rewrite module
  • Possibility to add more than 1 tag at the time by comma separating them in the "add item" box
  • Recursively set the same tags from an album to it's children and sub-children
  • Bulk Edit Tags for items in the same album like "Edit Captions"
  • Ability to Change the Tag Cloud CSS from the admin page
  • Tag Cloud as a side-bar Block
  • Tags can be added from under the pictures (Theme needs to display the summaries)
  • See tag matches in main search page


  • Login as admin
  • Select Plugins from the left navigation
  • Click the Get More Plugins tab.
  • Click the Show repository list button.
  • Check the Community plugins box; Save
  • Click the update repository list button; click continue.
  • Under the Extra Data section download the the tags module.

Upgrades to module

  • Login as admin
  • Select Plugins from the left navigation
  • Click the Get More Plugins tab.
  • Click the Show repository list button.
  • Check the Community plugins box; Save
  • Click the update repository list button; click continue.
  • Under the Extra Data section upgrade the the tags module.

Import key words

This task will go throught all the gallery item and copy all of the keywords into the tags, if the tag exists, it will not be duplicated existing tags will be kept. This is a Maintenance task:

  • login as admin; Site admin; Admin options -> Maintenance "Copy my Keywords into the tags" -> run now


URL Rewite

If the URL Rewrite module is in use, you can activate the rule(s) for virtual albums and the tag 'cloud'.

  • Login as admin, site admin, URL rewrite. Under the Tags Module section you are able to configure the:
    • Tag Cloud
    • Tag Virtual Album

Typical configuration

  • Defaults:
    • The Tags don't show up under the picture
    • The Tag Cloud link is hidden
    • The "Popular tags" are not limited (all tags shown)
  • These can be changed in the Tag Settings Page in the Site Admin

Requested Features for Next Version

  • Multi-tag Virtual Album: Say you have a tag called Canada and wanted to view flowers in Canada, you would have a link like: /tags/Canada-and-flowers. It would return a virtual album with items that are tagged Canada and flowers. Don't know how one would code for 2 word tags.
    • use a comma or semicolon for AND operations since this is what you use to separate tags when adding. This is how multiple keyword albums work.
    • perhaps a pipe separator (|) would work.
    • should support both OR and AND (i.e. Canada and Flowers vs Cars or Motorcycles)
    • Ability to build AND multi-tag virtual album through tag cloud. This will make it easy to find photos you are looking for.
      • Example:
      • First you click on "mom" in the tag cloud and you are shown all photos tagged with "mom".
      • The tag cloud shows only tags that are used together with "mom".
      • You select "dad" and get all photos tagged with "mom" and "dad".
      • The tag cloud shows only tags that are used together with both "mom" and "dad".
      • You select "Canada" and get all photos tagged with "mom", "dad" and "Canada".
  • Improve the Summary Interface: Make the Interface hidden, 1 click => show
  • Remove the refresh on tag addition => dynamically update the tags with AJAX
  • Auto-complete the tags input box using existing tags
    • e.g. typing the letters "Ma" and auto-complete would suggest existing tags "Maine", "Ma", "major" in a popup
    • for faster tagging you shout type coma separate tags with auto-complete
  • Add the bubble Template (
  • Add another block that just has the auto-complete search box.
  • Add thumbnail of item beside the edit tag (view=tags.TagsItemEdit) page.
  • Ability to move item tagged X into tag Y (conflate two tags)
    • eg change the tag 'portratis' wherever it occurs to 'portraits', even though the tag 'portraits' exists already.
  • Add tag box on photo page itself so users can tag it without (see request 1599539
  • Support tagging for anonymous users (users not signed in) and have a moderation page for admins to approve/reject anonymous tags
  • add multilingual support so that tags can be translated via multilingual module: this might also need a rewrite of multilingual module so that future modules can easily plug into multilingual module to have their content translated manually
  • CMS integration so that tag clouds from gallery from specific albums or whole gallery can be called via some code that is to be introduced in some content in a CMS where the tag cloud should appear
  • a possibility to limit the shown tags especial in the side bar
  • a blacklist to avoid unwanted tags
  • A whitelist of approved tags (to facilitate anonymous tagging with admin approval; see above)
  • being able to change theme settings for dynamic tag albums (like the Ratings module)
  • A contextual tag cloud based upon current location within the Gallery (e.g. the tag cloud for /v/ is for the entire Gallery2 item space, but the tag cloud /v/misc/ shows only the tags that have been assign to /v/misc/ and its children)
  • Ability to Bulk Edit the tags on items that are shown in a Tag dynamic album
  • A tag query builder (requires multi-tag album support): Something like the iTunes smart playlist builder:
    • [Tag] [Does|Does Not] Contain [Text] AND
    • [Tag] [Does|Does Not] Contain [Text] OR
    • etc etc. This interface could also be used in conjunction with other metadata stored with the items (Date, Description, Summary, whatever) to create truly versatile dynamic albums
  • Ability to remove tags on Bulk Edit Tags page
  • Display the Item Actions block on the tag related pages, if it's in the sidebar usually.
  • Option to copy keywords into tags only for images that have been added to the gallery since the last time that task was run.
  • Apply tag data to "Alt" element of HTML IMG markup
  • Slideshow of the Dynamic Tag Album
  • Ability to add a description in the Dynamic Tag Album
  • A maintenance task for copying IPTC keywords to tags in the Gallery2 database.

Other Requests

  • It would be nice to be able to permission and such via tags. Tags are so fast and easy to edit in desktop photo gallery applications. I don't really want to separate all my photos into separate batches/albums/whatever in order to permission them. I'd like to just add a tag like "public web" to all of the pictures that aren't crap, and then set some permission saying "only show photos with the tag 'public web'", etc. I would then assume that any photos that didn't meet the permissioning requirements would be filtered from all search results etc, and would only appear to the admin user. Other tags could certainly still be added; making tags permissionable shouldn't take away from any of the other tagging functionality. I just installed Gallery2 today, ... I had assumed that it would all work this way. I'm a little confused now as how to best make use of the gallery software. At least half of my pictures are crap. I don't want to have to manually move half the pictures into separate folders/albums etc, nor do I want to delete all the pictures that I don't quite like as much. It seems to me that most people would have similar issues. (implementation of this in the discussion section)
  • How about making the tags fuzzier, like the keywords? Such as, non case-sensitive, follow partials, like Keywords. For example -- if someone hits a tag for "zombie," they'll also get "zombies" and "The Zombie," and "Zombie Hunter," etc. You get the idea!
  • A "return to picture" or "return to album" link when finished editing tags would be nice.
  • Include tags search in the embedded gallery module.


  • Tag Name with Ampersand sign in them (like B&W) or with slashes (like AC/DC) do not generate the correct VirtualAlbum when URL rewrite is active
  • Security needs improvement, see for details
  • Folders (classes/, images/, js/ and templates/) in the tags/ plugin folder (gallery/modules/tags/) appear to be created in 744 mode, despite the 755 settings in Site admin. You must manually change these (chmod 755 classes, etc.) if you want the tags to work. You can check it by manually typing in you browser url: <your gallery url>gallery/modules/tags/js/Tags.js for example.
  • styles for tag cloud didn't load on root page of gallery because it was linked to the code base url in a multisite installation. I fixed this by adding option forceServerRelativeUrl=true for generateUrl in
  • Tag name with apostrophe breaks javascript unassignTag call -- should be escaped.


  • Is there a way to control the sort order of the "Tag" gallery?
    • Yes: site admin -> themes, select your theme and then you set the 'Default sort order'.