diff --git a/classes/text.class.php b/classes/text.class.php
index 94af9b3dd..871dd0396 100644
--- a/classes/text.class.php
+++ b/classes/text.class.php
@@ -1011,7 +1011,7 @@ class Text {
$Str .= '' . $Block['Val'] . ' (image)';
break;
}
- if (!self::valid_url($Block['Val'], '\.(?:jpe?g|gif|png|bmp|tiff|webp|svg)')) {
+ if (!self::valid_url($Block['Val'], '\.(?:avif|bmp|gif|jpe?g|png|svg|tiff|webp)')) {
$Str .= "[img]{$Block['Val']}[/img]";
} else {
$LocalURL = self::local_url($Block['Val']);
diff --git a/tests/phpunit/TextTest.php b/tests/phpunit/TextTest.php
index 4ba1168d7..7e025f785 100644
--- a/tests/phpunit/TextTest.php
+++ b/tests/phpunit/TextTest.php
@@ -91,16 +91,17 @@ class TextTest extends TestCase {
}
public function testImage(): void {
- $image = 'https://www.example.com/a.jpg';
- $withCache = '@^
$@';
- $noCache = "
";
+ $bad = "[img=https://www.example.com/a.pdf]";
+ $this->assertEquals($bad, $bad, "text-image-bad");
- $this->assertEquals($noCache, Text::full_format("[img=$image]"), 'text-image1-cache-implicit');
- // $this->assertEquals($noCache, Text::full_format("[img=$image]", cache: false), 'text-image1-cache-false');
- $this->assertEquals($noCache, Text::full_format("[img]{$image}[/img]"), 'text-image2-cache-implicit');
- // $this->assertEquals($noCache, Text::full_format("[img]{$image}[/img]", cache: false), 'text-image2-cache-false');
- // $this->assertMatchesRegularExpression($withCache, Text::full_format("[img=$image]", cache: true), 'text-image1-cache-true');
- // $this->assertMatchesRegularExpression($withCache, Text::full_format("[img]{$image}[/img]", cache: true), 'text-image2-cache-true');
+ foreach (['avif', 'bmp', 'gif', 'jpg', 'jpeg', 'png', 'svg', 'tiff', 'webp'] as $ext) {
+ $image = "https://www.example.com/a.jpg";
+ $withCache = '@^
$@';
+ $noCache = "
";
+
+ $this->assertEquals($noCache, Text::full_format("[img=$image]"), "text-image1-cache-implicit-$ext");
+ $this->assertEquals($noCache, Text::full_format("[img]{$image}[/img]"), "text-image2-cache-implicit-$ext");
+ }
}
public function testCollage(): void {