Summary
This branch adds shared media listing/viewer infrastructure for videos and images, introduces grid/list gallery controls, improves viewer pages, and adds a comments/voting API without changing the database schema.
Media listing pages
- Added shared media listing helpers in
lib/media_listing.php. - Unified much of the
?vidand?imglisting behavior while keeping separate routes. - Added list/grid view switching for media listings.
- Stores listing view preference in a shared media cookie.
- Keeps detailed list view as the default.
- Added configurable media listing defaults in
config.php/config.local.php:- default listing view
- listing view cookie name
- items-per-page cookie name
- default items per page
- max items per page
- allowed page size options
- video thumbnail preference scheme
- image thumbnail preference scheme
- Added side-panel controls for:
- Detailed/Grid view
- 12/24/48 assets per page
- sort order
- uploader filtering
- Added username autocomplete/suggestions for uploader filtering.
- Internally resolves uploader username to UID for the existing API.
- Added fake users-page-style pagination for
?vidand?img. - Added row/card hover highlighting.
- Added avatar hydration for listing cards.
- Fixed double-escaped media titles such as
I'm. - Video thumbnails now prefer configured higher-resolution thumbnails and fall back in-browser instead of blocking page render with server-side checks.
- Changed media listing layout so the right sidebar is in normal document flow and no longer clips through the footer.
Viewer pages
- Added shared viewer helpers in
lib/media_viewer.php. - Reworked
?vand?pviewer pages around shared header/comment rendering. - Added separate viewer metadata header showing:
- title
- views
- vote count
- score
- upvote/downvote controls
- uploader
- uploader avatar
- published date
- download links
- owner/admin actions
- description
- Video descriptions are collapsed by default with Show more/Show less behavior.
- Replaced old table-based comment form markup.
- Improved comment styling and visibility.
- Added related-media sidebars on viewer pages:
- same-media only
- videos on video pages
- images on image pages
- current item pinned first and unclickable
- other public uploads from same user shown underneath
- Changed viewer layout so sidebars are in normal document flow and no longer clip through the footer.
- Fixed video iframe sizing by replacing
height:100vh; max-height:70vhwith a proper 16:9 wrapper.
Comments and votes
- Added
api/comments.php. - Supports:
- loading comments for a media item
- posting comments
- replying to comments
- replying to media-vote rows
- editing own comments
- soft-deleting own comments without schema changes
- media upvote/downvote stored as empty comment rows
- per-user comment/vote stats
- Media votes use the existing
comments.lkefield with1/-1. - Vote summary includes:
- total votes
- score
- upvotes
- downvotes
- current user vote
- Comment count includes replies.
User pages
- Made
Videos NandImages Nprofile stats clickable. - Links go to filtered
?vid/?imgsearches for that user. - Added user comment and vote count stats using the comments API.
- Added hover highlighting to the users table and mobile user cards.
Upload/restore maintenance
- Reworked
upl/v/resolutions.php.- Fixed broken loop.
- Uses configured CDN root instead of hardcoded paths.
- Uses escaped shell paths for probing.
- Extracts width, height, duration, and FPS.
- Upserts into
resolutions. - Allows CLI use, but requires admin privilege when called through web.
- Reworked
upl/v/restore.php.- Preserves restore behavior, thumbnail regeneration, and conversion queueing.
- Uses safer metadata probing.
- Upserts
resolutions. - Detects missing audio and queues silent audio fallback when needed.
- Uses prepared DB statements.
- Writes JSON metadata with
file_put_contents. - Returns JSON responses.
TODO updates
Added TO-DO.md entries for work that requires API/schema changes or future design:
- real video duration in media listings
- standardizing media routes further
- total counts in list API
- native uploader-name search in media API
- filesize metadata/sort
- resolution metadata/sort
- comment search
- vote search
comments.is_deleted- comment voting
- comment charset/schema migration
Constraints respected
- No database schema changes.
- No changes to the existing public media API contract.
- Only added a new comments API.
- Existing
?vid,?img,?v,?p, and?userroutes remain intact.
Verification
Ran:
php tests/run.php
Result:
All 90 tests passed.