fof / polls
A Flarum extension that adds polls to your discussions
Fund package maintenance!
Requires
- flarum/core: ^2.0.0
Requires (Dev)
- flarum/phpstan: ^2.0.0
- flarum/testing: ^2.0.0
- 3.0.0-beta.4
- 3.0.0-beta.3
- 3.0.0-beta.2
- 3.0.0-beta.1
- v2.x-dev
- 2.3.4
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3.0
- 2.3.0-beta.6
- 2.3.0-beta.5
- 2.3.0-beta.4
- 2.3.0-beta.3
- 2.3.0-beta.2
- 2.3.0-beta.1
- 2.3.0-beta.0
- 2.2.15
- 2.2.14
- 2.2.13
- 2.2.12
- 2.2.11
- 2.2.10
- 2.2.9
- 2.2.8
- 2.2.7
- 2.2.6
- 2.2.5
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.2.0-beta.17
- 2.2.0-beta.16
- 2.2.0-beta.15
- 2.2.0-beta.14
- 2.2.0-beta.13
- 2.2.0-beta.12
- 2.2.0-beta.11
- 2.2.0-beta.10
- 2.2.0-beta.9
- 2.2.0-beta.8
- 2.2.0-beta.7
- 2.2.0-beta.6
- 2.2.0-beta.5
- 2.2.0-beta.4
- 2.2.0-beta.3
- 2.2.0-beta.2
- 2.2.0-beta.1
- 2.2.0-alpha.9
- 2.2.0-alpha.8
- 2.2.0-alpha.7
- v2.2-alpha.6
- v2.2-alpha.5
- 2.2.0-alpha.4
- 2.2.0-alpha.3
- 2.2.0-alpha.2
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.1
- 2.0.0
- 1.x-dev
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.0
- 1.2.1
- 1.2.0
- 1.1.0
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.4.1
- 0.4.0
- 0.3.3
- 0.3.2
- 0.3.1
- 0.3.0
- 0.2.1
- 0.2.0
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- dev-gg/feat-draft-support-global-polls-2x
- dev-gg/feat-draft-support-global-polls
- dev-gg/improve-poll-settings
- dev-ds/split-v2-migrations-further
- dev-cw/image-url-with-dist
- dev-cw/composer-state-fields
- dev-beta13
This package is auto-updated.
Last update: 2026-05-21 21:43:48 UTC
README
A Flarum extension that adds polls to your discussions.
Installation
composer require fof/polls:"*"
Updating
composer update fof/polls php flarum migrate php flarum cache:clear
Features
- 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
Global Polls
What Are Global Polls?
Global polls are polls that exist on their own, independent of any discussion. Instead of being attached to a post, they appear on a dedicated Polls page accessible from the main navigation, where members can browse and vote on them as standalone items.
What Can You Use Global Polls For?
- Community-wide votes: feature requests, governance decisions, or general-interest questions that shouldn't be buried inside a thread.
- Announcements & surveys: recurring satisfaction surveys, event planning, or quick "pulse" polls.
- Long-running questions: polls with end dates that stay discoverable on the page until they close.
Enabling Global Polls
- In the admin panel, open the Polls extension settings and enable Allow global polls.
- Grant the Start a global poll permission (
startGlobalPoll) to the groups you want to be able to create global polls. - A Polls link appears in the forum navigation, pointing at the page of published global polls.
How to Use
-
Create a global poll: Navigate to the Polls page and click New poll. Fill in the question, options, and any optional settings (end date, image, multiple votes, etc.), then publish.
-
Browse & filter: The page supports sorting (newest, most voted, ending soon) and a status filter (All / Published / Drafts). Drafts are only visible to their author, moderators, and administrators.
-
Vote: Open a poll to cast your vote and see the results.
Permissions
- Start a global poll (
startGlobalPoll): who can create global polls. In practice this is usually limited to administrators and moderators. - Moderate polls (
discussion.polls.moderate): moderators can edit, delete, publish, and unpublish any global poll.
Drafts & Scheduled Publication
Global polls can be saved as drafts, published manually, or scheduled to go live at a specific time. This lets you prepare a poll in advance and have it appear on the Polls page automatically when the scheduled moment arrives.
How to Use
-
Create a draft: On the global poll compose page, click Save as draft. The poll is stored with
published_at = NULLand does not appear on the public Polls page. -
Publish manually: From either the compose page or the poll controls menu, click Publish to mark the draft as published immediately.
-
Schedule publication: Click the clock icon next to the Publish button (or Schedule publication in the controls menu) and pick a datetime. The poll stays in draft state until a cron-driven command publishes it.
-
Cancel a schedule: Use Cancel schedule in the controls menu to clear the scheduled time and keep the poll as a draft.
Cron setup (required for scheduled publication)
Scheduled drafts are published by Flarum's built-in task scheduler. If you don't already run it, open your crontab:
crontab -e
And add:
* * * * * cd /path/to/flarum && php flarum schedule:run
A single schedule:run entry covers scheduled polls and any other extension that registers scheduled tasks — you don't need a polls-specific line. Our task runs every minute and takes row-level locks, so multiple workers (e.g. an ECS deployment with N > 1 tasks) won't double-publish the same poll.
If a scheduled draft fails validation at publish time (missing question, fewer than two options, etc.), the error is recorded on the poll and future runs skip it until the author fixes the issue and re-schedules.
Image Handling
WebP Conversion & srcset
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.
Converting Existing Images
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-images
This 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 --cleanup
Image Settings
Configure 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 |
Metadata Refresh
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:refresh
Deprecations
External Image URLs (Deprecated in 2.0)
Will 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
For Extension Developers
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
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
Links
An extension by FriendsOfFlarum.