Open
Description
Current Behavior
When checking for image variations, ProcessWire only detects variations with different extensions (like .webp or .avif) if there exists at least one variation with the same extension as the original image.
For example:
- If original image is
image.jpg
:- ✅ Detected: Having both
image.0x260.jpg
andimage.0x260.webp
- ❌ Not Detected: Having only
image.0x260.webp
withoutimage.0x260.jpg
- ❌ Not Detected: Having only
image.-custom-suffix.webp
- ✅ Detected: Having both
Expected Behavior
ProcessWire should be able to detect all variations regardless of their file extension, allowing for:
- Direct creation of .webp/.avif variations without requiring a same-extension variant
- Custom suffixes with different extensions to be recognized as valid variations
Example
With an original image image.jpg
, these variations should be directly detectable:
We can use something like (for get all variations):
$pathinfo = pathinfo($image->filename);
// can you also add this function to WireFileTools::glob(string|array $pattern)
$getVariations = function(string $pattern): array {
// Try with GLOB_BRACE first
$variations = glob($pattern, GLOB_NOSORT | GLOB_BRACE);
// If no results with GLOB_BRACE, try without it
if (!$variations) {
$variations = glob($pattern, GLOB_NOSORT) ?: [];
}
return $variations;
};
// get suffix variations
bd($getVariations("{$pathinfo['dirname']}/{$pathinfo['filename']}.[cpd0-9-]*.*"));