Image Comparison Elo Rating System GitLab
A WordPress plugin that allows users to compare images pairwise using an Elo rating system and view rankings based on user preferences.
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://gitlab.com/engza/wp-plugin-ice/-/archive/main/wp-plugin-ice-main.zipWP Plugin - Image Comparison Elo (ICE)
A WordPress plugin that allows users to compare images pairwise using an Elo rating system and view rankings based on user preferences.
Description
The Image Comparison Elo plugin enables users to compare images within a specified category using a simple "Choose" interface. It calculates Elo ratings based on user selections and displays a ranked list of images with star ratings (1-5 stars). The plugin is designed for performance, accessibility, and user engagement, with features like clickable thumbnails and keyboard navigation.
Features
- Pairwise Image Comparison: Users compare two images at a time and select their preferred option.
- Elo Rating System: Automatically calculates ratings based on user choices using the Elo algorithm.
- Rankings Table: Displays a paginated list of ranked images with star ratings (1-5) and titles.
- Performance Optimization: Uses
thumbnailsize for rankings andmediumsize for comparisons, with fallback to full-size images. - Accessibility: Includes ARIA roles, keyboard navigation, and screen reader support.
- Clickable Thumbnails: Thumbnails link to full-size images in a new tab.
Requirements
- WordPress 5.0 or higher
- PHP 7.0 or higher
- jQuery (included with WordPress)
Installation
-
Download the Plugin:
- Clone this repository or download the ZIP file:
git clone https://gitlab.com/engza/wp-plugin-ice.git
- Clone this repository or download the ZIP file:
-
Upload to WordPress:
- Upload the
image-comparison-elofolder to the/wp-content/plugins/directory on your WordPress installation.
- Upload the
-
Activate the Plugin:
- Log in to your WordPress admin panel.
- Navigate to Plugins > Installed Plugins.
- Find Image Comparison Elo and click Activate.
-
Set Up Categories:
- Upload images to the WordPress Media Library and assign them to categories (custom taxonomy or media categories plugin required).
Usage
Shortcodes
-
Image Comparison (
[image_compare]):- Display two random images from a category for comparison.
- Example:
[image_compare category="phones"] - Users can click "Choose" to vote for their preferred image or "Skip" to load new images.
-
Image Rankings (
[image_rankings]):- Display a ranked list of images based on Elo ratings.
- Examples:
[image_rankings category="phones" per_page="15"][image_rankings category="phones"] - Attributes:
category: The category slug (required).per_page: Number of images per page (optional, default: 10).
Example Output
-
Comparison:
[Medium Image: iPhone 12] [Medium Image: Galaxy S21] Choose Choose Skip- Clicking an image opens the full-size version in a new tab.
-
Rankings:
Rank | Image | Rating 1 | [Thumbnail] | ★★★★★ (1200) | iPhone 12 | 2 | [Thumbnail] | ★★★★☆ (1100) | Galaxy S21 |- Thumbnails link to full-size images.
Configuration
-
Image Sizes:
- Adjust sizes in Settings > Media:
thumbnail: Used in rankings (default: 150x150).medium: Used in comparisons (default: 300x300).
- Regenerate thumbnails after changes using a plugin like Regenerate Thumbnails.
- Adjust sizes in Settings > Media:
-
Custom Sizes (Optional):
- Add to your theme’s
functions.phpor the plugin’s main file:add_action('after_setup_theme', function() { add_image_size('ice-compare', 400, 300, false); // Custom size for comparisons }); - Update
compare_shortcodeto use'ice-compare'instead of'medium'.
- Add to your theme’s
Development
File Structure
image-comparison-elo/
├── assets
│ ├── css
│ │ └── frontend.css
│ └── js
│ └── frontend.js
├── includes
│ ├── class-ajax.php
│ ├── class-elo-rating.php
│ ├── class-media-category.php
│ ├── class-settings.php
│ └── class-shortcodes.php
├── image-comparison-elo.php
└── README.md
Key Classes
-
ICE_Shortcodes(includes/class-shortcodes.php):- Handles shortcode logic for
[image_compare]and[image_rankings]. - Includes helper functions for star ratings and image URL fallbacks.
- Handles shortcode logic for
-
ICE_Elo_Rating(assumed in the plugin):- Manages Elo rating calculations and database interactions.
Contributing
- Fork this repository on GitLab.
- Create a new branch:
git checkout -b feature/your-feature-name - Commit your changes:
git commit -m "Add your feature description" - Push to your fork:
git push origin feature/your-feature-name - Open a Merge Request on GitLab.
Issues
Report bugs or suggest features via the GitLab Issues page.
License
This plugin is licensed under the GPLv2 or later, compatible with WordPress.
Credits
Developed by Zach Engstrom. Inspired by Elo rating systems used in competitive rankings.