diff --git a/system/src/Grav/Common/Page/Medium/Medium.php b/system/src/Grav/Common/Page/Medium/Medium.php index 342efb3ae..3eea145e4 100644 --- a/system/src/Grav/Common/Page/Medium/Medium.php +++ b/system/src/Grav/Common/Page/Medium/Medium.php @@ -229,7 +229,7 @@ class Medium extends Data implements RenderableInterface } if (empty($attributes['alt'])) { - if (!empty($alt)) { + if (!empty($alt) || $alt === '') { $attributes['alt'] = $alt; } elseif (!empty($this->items['alt'])) { $attributes['alt'] = $this->items['alt']; diff --git a/tests/unit/Grav/Common/Markdown/ParsedownTest.php b/tests/unit/Grav/Common/Markdown/ParsedownTest.php index c3a2c2634..bbd1cad3a 100644 --- a/tests/unit/Grav/Common/Markdown/ParsedownTest.php +++ b/tests/unit/Grav/Common/Markdown/ParsedownTest.php @@ -78,18 +78,18 @@ class ParsedownTest extends \Codeception\TestCase\Test $this->grav['language'] = new Language($this->grav); $this->uri->initializeWithURL('http://testing.dev/fr/item2/item2-2')->init(); - $this->assertSame('

', + $this->assertSame('

', $this->parsedown->text('![](sample-image.jpg)')); - $this->assertRegexp('|

<\/p>|', + $this->assertRegexp('|

<\/p>|', $this->parsedown->text('![](cache-image.jpg?cropResize=200,200&foo)')); $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init(); - $this->assertSame('

', + $this->assertSame('

', $this->parsedown->text('![](sample-image.jpg)')); - $this->assertRegexp('|

<\/p>|', + $this->assertRegexp('|

<\/p>|', $this->parsedown->text('![](cache-image.jpg?cropResize=200,200&foo)')); - $this->assertRegexp('|

<\/p>|', + $this->assertRegexp('|

<\/p>|', $this->parsedown->text('![](/home-cache-image.jpg?cache)')); $this->assertSame('

', $this->parsedown->text('![](missing-image.jpg)')); @@ -106,11 +106,11 @@ class ParsedownTest extends \Codeception\TestCase\Test { $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init(); - $this->assertRegexp('|

<\/p>|', + $this->assertRegexp('|

<\/p>|', $this->parsedown->text('![](/home-cache-image.jpg?cache)')); - $this->assertSame('

', + $this->assertSame('

', $this->parsedown->text('![](sample-image.jpg)')); - $this->assertRegexp('|

<\/p>|', + $this->assertRegexp('|

<\/p>|', $this->parsedown->text('![](cache-image.jpg?cache)')); $this->assertSame('

', $this->parsedown->text('![](missing-image.jpg)')); @@ -124,11 +124,11 @@ class ParsedownTest extends \Codeception\TestCase\Test $this->config->set('system.absolute_urls', true); $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init(); - $this->assertSame('

', + $this->assertSame('

', $this->parsedown->text('![](sample-image.jpg)')); - $this->assertRegexp('|

<\/p>|', + $this->assertRegexp('|

<\/p>|', $this->parsedown->text('![](cache-image.jpg?cache)')); - $this->assertRegexp('|

<\/p>|', + $this->assertRegexp('|

<\/p>|', $this->parsedown->text('![](/home-cache-image.jpg?cache)')); $this->assertSame('

', $this->parsedown->text('![](missing-image.jpg)')); @@ -141,11 +141,11 @@ class ParsedownTest extends \Codeception\TestCase\Test $this->config->set('system.absolute_urls', true); $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init(); - $this->assertSame('

', + $this->assertSame('

', $this->parsedown->text('![](sample-image.jpg)')); - $this->assertRegexp('|

<\/p>|', + $this->assertRegexp('|

<\/p>|', $this->parsedown->text('![](cache-image.jpg?cache)')); - $this->assertRegexp('|

<\/p>|', + $this->assertRegexp('|

<\/p>|', $this->parsedown->text('![](/home-cache-image.jpg?cropResize=200,200)')); $this->assertSame('

', $this->parsedown->text('![](missing-image.jpg)')); @@ -157,13 +157,13 @@ class ParsedownTest extends \Codeception\TestCase\Test { $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init(); - $this->assertSame('

', + $this->assertSame('

', $this->parsedown->text('![](sample-image.jpg "My Title")')); - $this->assertSame('

', + $this->assertSame('

', $this->parsedown->text('![](sample-image.jpg?classes=foo)')); - $this->assertSame('

', + $this->assertSame('

', $this->parsedown->text('![](sample-image.jpg?classes=foo,bar)')); - $this->assertSame('

', + $this->assertSame('

', $this->parsedown->text('![](sample-image.jpg?id=foo)')); $this->assertSame('

Alt Text

', $this->parsedown->text('![Alt Text](sample-image.jpg?id=foo)')); @@ -188,11 +188,11 @@ class ParsedownTest extends \Codeception\TestCase\Test $page = $this->pages->dispatch('/'); $this->parsedown = new Parsedown($page, $defaults); - $this->assertSame('

', + $this->assertSame('

', $this->parsedown->text('![](home-sample-image.jpg)')); - $this->assertRegexp('|

<\/p>|', + $this->assertRegexp('|

<\/p>|', $this->parsedown->text('![](home-cache-image.jpg?cache)')); - $this->assertRegexp('|

<\/p>|', + $this->assertRegexp('|

<\/p>|', $this->parsedown->text('![](home-cache-image.jpg?cropResize=200,200&foo)')); $this->assertSame('

', $this->parsedown->text('![](/home-missing-image.jpg)')); @@ -202,7 +202,7 @@ class ParsedownTest extends \Codeception\TestCase\Test $this->grav['language'] = new Language($this->grav); $this->uri->initializeWithURL('http://testing.dev/fr/item2/item2-2')->init(); - $this->assertSame('

', + $this->assertSame('

', $this->parsedown->text('![](home-sample-image.jpg)')); @@ -213,11 +213,11 @@ class ParsedownTest extends \Codeception\TestCase\Test $this->config->set('system.absolute_urls', true); $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init(); - $this->assertSame('

', + $this->assertSame('

', $this->parsedown->text('![](sample-image.jpg)')); - $this->assertRegexp('|

<\/p>|', + $this->assertRegexp('|

<\/p>|', $this->parsedown->text('![](cache-image.jpg?cache)')); - $this->assertRegexp('|

<\/p>|', + $this->assertRegexp('|

<\/p>|', $this->parsedown->text('![](/home-cache-image.jpg?cropResize=200,200)')); $this->assertSame('

', $this->parsedown->text('![](missing-image.jpg)'));