A WordPress plugin that enhances the Etch page builder with improved image handling and focus position support.
Automatically enhances images in Etch blocks with essential attributes:
- Responsive Images: Adds
srcsetattributes for different screen sizes - Dimensions: Extracts
widthandheightfrom filename or metadata - Accessibility: Adds
alttext from attachment metadata - Decorative Images: Use
alt="-"(hyphen) to mark images as decorative - Performance: Generates
sizesattributes for optimal image loading - Smart Detection: Only adds missing attributes, never overwrites existing ones
- Optimized: Early-exit for images with complete attributes (minimal overhead)
- Efficient: Runtime cache prevents duplicate database queries
Integrates with focus point plugins to control image focal points:
- Applies CSS
object-positionbased on focus point data - Per-page overrides: Set custom focus points in Etch editor that override global Media Library values
- Visual editor: Click-to-set focus point UI in Etch's element settings panel
- Dynamic Data integration: Access focus points via
{this.image.focusPoint}in Etch templates - Compatible with:
The Focus Point Editor appears automatically when you select an image in the Etch canvas. It provides:
- Interactive Preview: Click anywhere on the image thumbnail to set the focus point
- Visual Marker: A crosshair marker shows the current focus position
- Position Display: Shows exact percentage values (e.g., "30.5% 45.2%")
- Override Indicator: Clearly shows whether you're using a page-specific override or the global Media Library value
- Reset Button: One click to remove the override and revert to the global focus point
- Etch page builder (v1.0.0 or higher recommended)
- PHP 8.1 or higher
- WordPress 5.9 or higher
For focus position features, install one of:
- Image Background Focus Position plugin
- Media Focus Point plugin
- Ensure Etch page builder is installed and activated
- Upload the
mwe-etchwp-enhancementsfolder to/wp-content/plugins/ - Activate the plugin through the WordPress 'Plugins' menu
- (Optional) Install a focus position plugin for focal point features
Add to your theme's functions.php:
// Disable image enhancement
add_filter( 'mwe_etchwp_enable_image_enhancement', '__return_false' );
// Disable focus position
add_filter( 'mwe_etchwp_enable_focus_position', '__return_false' );Add to wp-config.php:
// Disable image enhancement
define( 'MWE_ETCHWP_IMAGE_ENHANCEMENT', false );
// Disable focus position
define( 'MWE_ETCHWP_FOCUS_POSITION', false );- Hooks into
render_blockfilter (priority 15) after Etch processes blocks - Detects
<img>tags in supported Etch blocks - Performance check: Skips images that already have all attributes (early-exit)
- Cache check: Returns cached attachment ID if image was previously processed
- Attempts to find attachment ID from image URL using multiple strategies
- Checks which attributes are missing
- Adds only the missing attributes without modifying existing ones
- Caches result: Stores attachment ID for future lookups within the same request
Full processing (image enhancement + focus position):
etch/element- Standard HTML elementsetch/dynamic-element- Dynamic HTML elementsetch/raw-html- Raw HTML blocksetch/component- Component blocks
Focus position only:
etch/dynamic-image- Dynamic Image element (Etch 1.0.0-beta-15+)
The Dynamic Image element in Etch already handles responsive image attributes (srcset, sizes, width, height) internally. This plugin only applies focus position styling to these images to avoid conflicts and duplicate processing.
- Reads focus point data from compatible plugins
- Adds data to attachment metadata via
wp_get_attachment_metadatafilter - Checks for per-page overrides stored in post meta
- Applies CSS
object-positionduring block rendering (override > global > default) - Automatically applies image enhancements as well (except for
etch/dynamic-image)
Focus points can be customized per-page in the Etch editor:
- Select an image in the Etch canvas
- Find the "Focus Point" section in Element Settings
- Click on the preview image to set the focus point
- The override is saved automatically for this page only
- Click "Use Global" to remove the override and use the Media Library value
Priority order:
- Per-page override (set in Etch editor)
- Media Library focus point (global)
- Default:
50% 50%(center)
Control whether image enhancement is enabled.
/**
* @param bool $enabled Default: true
* @return bool
*/
apply_filters( 'mwe_etchwp_enable_image_enhancement', true );Control whether focus position feature is enabled.
/**
* @param bool $enabled Default: true
* @return bool
*/
apply_filters( 'mwe_etchwp_enable_focus_position', true );Customize which Etch block types are processed for image enhancement and focus position.
/**
* @param array $processable_blocks Default: ['etch/element', 'etch/dynamic-element', 'etch/raw-html', 'etch/component', 'etch/dynamic-image']
* @return array
*/
apply_filters( 'mwe_etchwp_processable_blocks', $processable_blocks );Example usage:
// Add a custom block type to processing
add_filter( 'mwe_etchwp_processable_blocks', function( $blocks ) {
$blocks[] = 'etch/custom-block';
return $blocks;
} );
// Remove a specific block from processing
add_filter( 'mwe_etchwp_processable_blocks', function( $blocks ) {
return array_diff( $blocks, array( 'etch/raw-html' ) );
} );Customize which blocks should skip responsive image processing (srcset, sizes, width, height). These blocks still receive focus position processing.
/**
* @param array $skip_blocks Default: ['etch/dynamic-image']
* @return array
*/
apply_filters( 'mwe_etchwp_skip_responsive_blocks', $skip_blocks );Example usage:
// Add another block that handles its own responsive images
add_filter( 'mwe_etchwp_skip_responsive_blocks', function( $blocks ) {
$blocks[] = 'etch/custom-responsive-block';
return $blocks;
} );Enable/disable image enhancement feature.
define( 'MWE_ETCHWP_IMAGE_ENHANCEMENT', false );Enable/disable focus position feature.
define( 'MWE_ETCHWP_FOCUS_POSITION', false );GitHub Personal Access Token to avoid API rate limits when checking for updates. Without a token, GitHub limits requests to 60/hour which can cause "Could not determine if updates are available" errors.
define( 'MWE_ETCHWP_GITHUB_TOKEN', 'ghp_your_token_here' );To create a token:
- Go to GitHub → Settings → Developer settings → Personal access tokens → Tokens (classic)
- Generate new token with
public_reposcope (for public repositories, no scope is actually needed) - Add the constant to your
wp-config.php
MWE\EtchWP_Enhancements\
├── Plugin # Main plugin class with dependency checks
├── Image_Enhancement # Handles image attribute enhancement
├── Focus_Position # Handles focus point integration
├── Focus_Dynamic_Data # Exposes focus points in Etch Dynamic Data
├── Focus_Ajax # AJAX handlers for focus point overrides
├── Focus_Editor_UI # Loads focus point editor UI in Etch canvas
└── Helper # Shared utility functions
All classes use the Singleton pattern and are autoloaded.
render_block: Priority 15 (runs after Etch at priority 10)wp_get_attachment_metadata: Priority 10plugins_loaded: Plugin initialization
mwe-etchwp-enhancements/
├── mwe-etchwp-enhancements.php # Main plugin file
├── README.md # This file
├── readme.txt # WordPress.org readme
├── includes/
│ ├── class-plugin.php # Main plugin class
│ ├── class-image-enhancement.php # Image enhancement feature
│ ├── class-focus-position.php # Focus position feature
│ ├── class-focus-dynamic-data.php # Etch Dynamic Data integration
│ ├── class-focus-ajax.php # AJAX handlers for overrides
│ ├── class-focus-editor-ui.php # Editor UI asset loading
│ └── class-helper.php # Shared utilities
├── assets/
│ ├── js/
│ │ └── focus-point-editor.js # Visual focus point editor
│ └── css/
│ └── focus-point-editor.css # Editor UI styles
└── languages/
└── mwe-etchwp-enhancements.pot # Translation template
This plugin follows:
- WordPress PHP Coding Standards
- WordPress Documentation Standards
- PSR-4 autoloading with namespace
MWE\EtchWP_Enhancements - Strict typing with
declare(strict_types=1)
- Fixed: Focus points now work for external image URLs (not just wp-content/uploads)
- Fixed: PHP 8.5 deprecation warnings in test suite (removed unnecessary setAccessible calls)
- Added: Tests for external URL focus point handling
- Improved: Consolidated attachment ID lookups into central
Helper::get_attachment_id_from_url()method with caching - Improved: Consolidated duplicate
get_current_post_id()methods intoHelperclass - Improved: Added type declarations for
get_instance()methods (PHP 8.1+) - Added: Comprehensive test coverage for
HelperandImage_Enhancementclasses (52 tests total) - Code quality: Reduced ~50 lines of duplicate code, better maintainability
- Added: Support for GitHub Personal Access Token (
MWE_ETCHWP_GITHUB_TOKENconstant) to avoid API rate limits - Fixed: "Could not determine if updates are available" error caused by GitHub API rate limiting (403 errors)
- Added: Focus Point Editor now supports
etch:imgelements (Etch's native Image element) - Improved: Significantly faster panel switching when selecting different images (debounced DOM observers)
- Fixed: Theme filters for disabling features now work correctly when added in
functions.php - Changed: Plugin initialization moved to
after_setup_themehook for better filter compatibility
- Tested: Full compatibility with Etch 1.0.0-rc-7
- Confirmed: All expected blocks (element, dynamic-element, raw-html, component, dynamic-image) are still registered
- Verified: HTML output format unchanged (standard img tags, no wrapper elements)
- Note: No code changes required - plugin works with both beta-15 and rc-7
- Added: Support for new
etch/dynamic-imageblock (Etch 1.0.0-beta-15+) - Added: New filter
mwe_etchwp_skip_responsive_blocksto control which blocks skip responsive image processing - Note:
etch/dynamic-imagereceives focus position only (no srcset/sizes changes as Etch handles these)
- Fixed: Portrait images now display fully in Focus Point preview (no more clipping)
- Fixed: Focus Point UI now updates when image src is changed in panel
- Fixed: Height jump when Saving/Saved status appears
- Added: Automatic updates from GitHub Releases
- Added: One-click upgrade support via WordPress admin
- Added: Per-page focus point overrides in Etch editor
- Added: Visual focus point editor UI with click-to-set functionality
- Added: Dynamic Data integration (
{this.image.focusPoint}in Etch templates) - Added: AJAX endpoints for saving/retrieving focus point overrides
- Added: Focus overrides stored in post meta (
_mwe_etchwp_enhancements_focus_overrides) - Added: New classes:
Focus_Dynamic_Data,Focus_Ajax,Focus_Editor_UI - Changed: Focus points now use priority: per-page override > Media Library > default
- Fixed: Decorative images were being overwritten by Focus_Position filter
- Added:
data-decorative="true"attribute to prevent re-processing
- Fixed: Sizes attribute was not added when srcset already existed (inverted logic)
- Changed: New decorative image handling - use
alt="-"(hyphen) to mark images as decorative - Changed: Empty
alt=""now loads alt text from media library (previously kept empty)
- Fixed: Substring matching bug in attachment lookup that caused wrong srcset URLs (e.g., "Lang.webp" incorrectly matching "franz-jascha-lang.webp")
- Improved: Performance optimization - images with complete attributes are now skipped (no database queries)
- Improved: Runtime cache prevents duplicate database lookups for the same image within a request
- Improved: More precise attachment ID matching with exact filename comparison
- Fixed: Focus Position feature now initializes correctly regardless of plugin detection timing
- Fixed: Removed dependency check that prevented Focus Position from working in some cases
- Improved: Feature detection now happens at runtime instead of during initialization
- Fixed: Updated block type detection for Etch compatibility
- Changed: Now supports
etch/element,etch/dynamic-element,etch/raw-html, andetch/componentblocks - Added: New filter
mwe_etchwp_processable_blocksto customize which block types are processed - Removed: Support for legacy
etch/block(no longer exists in current Etch versions) - Improved: Better code documentation and centralized block detection logic
- Initial release
- Image enhancement with automatic srcset, dimensions, alt, and sizes
- Focus position integration for compatible plugins
- Dependency checking with admin notices
- Filters and constants for feature control
Author: Marco Michely Website: www.michelyweb.de Email: email@michelyweb.de
This plugin is licensed under the GPL v3 or later.
Copyright (C) 2025 Marco Michely
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
For bug reports and feature requests, please contact:
- Email: email@michelyweb.de
- Website: https://www.michelyweb.de
Made with ❤️ by Marco Michely

