A Flarum extension that adds polls to your discussions.
composer require fof/polls:"*"composer update fof/polls
php flarum migrate
php flarum cache:clear- Create polls in discussions or as standalone global polls
- Single and multiple choice voting
- Public/private vote visibility
- Poll end dates
- Poll images with WebP conversion and HiDPI (srcset) support
- Poll option images
- Poll groups for organizing global polls
- Granular permissions for poll creation, voting, and moderation
Uploaded images are automatically converted to WebP format (or preserved as GIF for animated images) and stored with responsive variants:
- Base (1x) - sized to admin-configured dimensions (default 250x250)
- @2x - double resolution for HiDPI displays
- @3x - triple resolution for ultra-high DPI displays
Variants are only generated when the source image is large enough — images are never upscaled.
The API response includes an imageSrcset field that browsers use to select the appropriate resolution automatically.
If you're upgrading from a previous version, existing PNG images can be converted to the new WebP format with srcset variants:
php flarum fof:polls:convert-imagesThis is optional — existing PNG images will continue to work without conversion. Add --cleanup to remove original PNG files after successful conversion:
php flarum fof:polls:convert-images --cleanupConfigure in the admin panel under the Polls extension settings:
| Setting | Default | Description |
|---|---|---|
| Allow image uploads | Off | Enable the image upload feature |
| Allow option images | Off | Enable images on individual poll options |
| Image width | 250 | Base width in pixels (2x and 3x derived automatically) |
| Image height | 250 | Base height in pixels |
To improve performance, Polls calculates and stores the number of votes when it changes.
If you made manual changes to the database you can refresh the numbers:
php flarum fof:polls:refreshWill be removed in the next major version.
Previous versions allowed pasting external image URLs directly. This is now deprecated in favour of the built-in upload system which provides:
- Proper image validation and security checks
- Automatic WebP conversion for better performance
- srcset variants for HiDPI displays
- Consistent storage and CDN support
What this means:
- Existing polls with external URL images will continue to display normally
- The URL paste input has been removed from the poll creation form
- When editing an existing poll with a URL image, a deprecation notice is shown encouraging re-upload
- Extensions that relied on
isImageUploadshould transition to checkingimageSrcsetpresence instead
If your extension integrates with fof/polls images:
isImageUploadfield — Deprecated on bothPollResourceandPollOptionResource. Use the presence ofimageSrcsetto determine if an image has responsive variants.PollImageWillBeResizedevent — Constructor signature updated to includeisAnimatedparameter. Update any listeners.PollImageUploaderservice — New service class for image operations. Use this instead of direct filesystem access for uploading, deleting, or generating srcset strings.- Frontend
<img>tags — Use theimageSrcset()model accessor and pass it as thesrcsetattribute.
Poll Groups allow you to organize multiple polls under a single topic. Enable via the admin setting "Enable poll groups".
Permissions:
- View poll groups — Controls who can see poll groups
- Create poll groups — Controls who can create new poll groups
- Moderate poll groups — Allows moderators to edit and delete any poll groups
An extension by FriendsOfFlarum.