Gallery2:Modules:rating - Gallery Codex
Personal tools


From Gallery Codex


The Gallery2 rating module was added in Gallery 2.1. It was written by Don Seiler (rizzo), with much help from valiant, mindless and bharat.


Gallery 2.2 adds a dynamic album view to show highly rated items from across the Gallery. Configure the theme, theme settings and sort order for this view in Site Admin.

User Interface

The Gallery2 rating module uses a 5-star interface for both user selection and average rating display. The default theme will use gold stars to represent the user's choice, and red outlines of stars to indicate the current average rating for that item.

The module was designed with themability in mind, so theme developers should have some flexibility in changing images and can also make use of a horizontal bar to display the average. The bar is hidden by default.


The star UI uses the latest in internet technology buzzwords, AJAX! What this means for the average user is that submitting a rating and updating of the rating display will happen without the page reloading. Javascript and behind-the-scenes HTTP calls will do the work and update the page.


The Gallery2 rating module makes full use of Gallery2's permissions system, and so a site admin can restrict adding and even viewing of item ratings to certain groups of users. A quick example would be to let Everyone view ratings, but only allow Registered Users to add ratings.


You will be able to sort items in an album by rating (both ascending and descending) if you wish to.

Vote Skew Protections

We are very aware of the possiblity of dastardly devils seeking to skew vote results in every manner of way, and the Gallery2 rating module does make efforts to curb this. Basically it only allows one vote per user per item. The trick comes into play when you allow anonymous users (Everyone) to cast votes. We will track the session ID and remote identifier information to do our best to identify unique visitors. We will add more safeguards as we are made aware of them in an effort to provide a fair rating system.


Will post when I can take some.


To enable rating you need to both enable the rating module and turn on rating for a given album under the Album Properties (Edit Album->Album tab).

Define the permissions (optionally for each album/item) by browsing to an album and clicking Edit Permission and adding/removing the add ratings, view ratings permission to specific user(s) or groups.

Add the ratings interface where you would like by selecting the ratings Block under the Edit Album->Theme tab blocks to add to the sidebar/album page/photo page


You can customize the look of the rating interface by adjusting the CSS, the templates and the images.

To adjust the CSS, open your themes/*/theme.css and add

 .giRatingUI img {}
 .giRatingUnit {}
 .giRatingHidden {}
 .giRatingVotes {}
 .giRatingEmpty {}
 .giRatingEmptyUserYes {}
 .giRatingHalfUserNo {}
 .giRatingHalfUserYes {}
 .giRatingFullUserNo {}
 .giRatingFullUserYes {}
 .giRatingAverage {}

of course you can set any CSS in between the {}. Also, you can change following CSS clases:

 .giRatingUI {
     margin: 10px auto; /* Required to center default rating module star images */
 #gsThumbMatrix .giRatingAverageContainer {
     margin: auto;

Bugs and Feature Requests

All bugs and featuer requests in the Gallery 2.1 module should be filed with Gallery's sourceforge bug and feature request trackers, respectively.

Any bugs with the gallery-contrib module should just be noted to Don Seiler by emailing don [at] seiler [dot] us. No new features will be accepted before the 2.1 release.


This module is an effort satisfy Task #106402. There is also a forum thread on the subject.

  • Remove rating specific CSS from theme.css and the css that needs to be there should be generalized, there should not be rating specific CSS in theme.css (we can't have a monolithic CSS file for our modular application)

Feature Requests

Change/erase ratings: Modify Rating enhancement

These should be added to the Gallery2 RFE tracker. --Rizzo 13:07, 16 December 2005 (PST)

I'm putting these in a priority order, and grouping what I see as dupes or related.

  1. Enable iconpack developers to include alternate stars that can be used in place of default stars --thumb 19:07, 22 November 2005 (PST)
  2. A block on the photo page or in the sidebar could have more than 1 line, so we could have 1 line to show your rating and 1 line to show the average
    • I think this is a theme issue. If we do things right then the theme can define it, but it would still be the same for item summaries vs blocks, since they use the same template.
  3. A top x rated items block
    • keep your pr0n site requests off here. or email them with a paypal donation ;) --Rizzo 08:32, 11 November 2005 (PST)
  4. Add other voting / rating styles, not just 5 stars. Maybe drop dwon / radio votes too, with user defined text...
  5. Enable voting option as an overlay of image blocks
  6. combine with the dynamic_view module in order to get a "top-of-album/subalbum" selection based on viewer's votes