Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/lwangdu/hero-random/archive/refs/heads/main.zipNo built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.
Random Hero Images is a WordPress plugin that adds a Gutenberg hero block powered by an ACF gallery field.
The block selects one random image from the gallery and overlays editable heading, text, and button content using InnerBlocks.
Status
- Current version:
1.2.7 - Distribution: GitHub
- Dependency: Advanced Custom Fields Pro
- PHP linting: passed on
hero-random.phpandinc/hero-random-block.php
Features
- Displays a random hero image from an ACF gallery field
- Supports heading, paragraph, and button content in the block editor
- Uses WordPress responsive image functions for
srcsetand attachment metadata - Includes accessibility improvements for hero labeling and image handling
- Fails gracefully when ACF is missing or the gallery field is misconfigured
Requirements
- WordPress 6.3 or newer
- PHP 7.4 or newer
- Advanced Custom Fields Pro
Installation
- Copy this plugin into
wp-content/plugins/hero-random. - Activate the plugin in WordPress.
- Make sure Advanced Custom Fields Pro is installed and active.
- Create or assign an ACF gallery field for the block.
- The plugin currently checks
hero_randomfirst and thengallery. - Add the
Random Hero Imagesblock in the editor. - Choose hero images that keep strong text contrast, especially for the desktop hero layout.
Development
- Main plugin file:
hero-random.php - Render template:
inc/hero-random-block.php - Stylesheet:
inc/hero-random.css - Local lint command:
/opt/homebrew/bin/php -l hero-random.php
/opt/homebrew/bin/php -l inc/hero-random-block.php
Screenshots
Add screenshots to docs/screenshots/ using these filenames:
editor-preview.pngfor the block in the editorfrontend-preview.pngfor the rendered hero on the front end
Editor Preview

Front-End Preview

Files
hero-random.phpplugin bootstrap and block registrationinc/hero-random-block.phpblock render templateinc/hero-random.cssshared front-end and editor stylingreadme.txtWordPress-style plugin readmedocs/screenshots/optional GitHub documentation images
Notes
- This plugin is distributed through GitHub and is not currently intended for the WordPress.org plugin directory.
- The block depends on ACF block registration and ACF gallery field data.
Changelog
1.2.7
- Kept gallery fallback messages in the editor only so they do not appear on the front end
- Prevented duplicate section IDs when a custom block anchor is set
- Removed inherited underlines from hero button links
- Improved WordPress coding standards alignment for PHP and CSS
1.2.6
- Refined desktop hero styling while keeping the mobile layout unchanged
- Improved hero accessibility by removing unnecessary live-region markup
- Tuned overlay contrast and button typography for better readability
1.2.5
- Improved accessibility for hero labeling and image handling
- Simplified stylesheet loading so editor and front end stay aligned
- Added safer gallery image resolution and attachment validation
- Added dependency notice and release metadata
- Added GitHub project documentation
License
GPL-2.0-or-later. See GNU GPL v2.0.