diff --git a/core/model/Image.php b/core/model/Image.php
index 7879fcc3b..83708e2f8 100755
--- a/core/model/Image.php
+++ b/core/model/Image.php
@@ -102,6 +102,15 @@ class Image extends File {
$url = $this->URL();
$title = ($this->Title) ? $this->Title : $this->Filename;
+ if ($this->Title) {
+ $title = $this->Title;
+ }
+ else {
+ // use the file name (without path and extension) for alt atttribute when the title is not defined
+ $title = $this->Filename;
+ if (preg_match("/([^\/]*)\.[a-zA-Z0-9]{1,6}$/", $title, $matches)) $title = $matches[1];
+ }
+
return "";
}
}
diff --git a/tests/model/ImageTest.php b/tests/model/ImageTest.php
new file mode 100644
index 000000000..f6f892ba4
--- /dev/null
+++ b/tests/model/ImageTest.php
@@ -0,0 +1,29 @@
+fixture->objFromFixture('Image', 'imageWithTitle');
+ $expected = '';
+ $actual = $image->getTag();
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ function testGetTagWithoutTitle() {
+ $image = $this->fixture->objFromFixture('Image', 'imageWithoutTitle');
+ $expected = '';
+ $actual = $image->getTag();
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ function testGetTagWithoutTitleContainingDots() {
+ $image = $this->fixture->objFromFixture('Image', 'imageWithoutTitleContainingDots');
+ $expected = '';
+ $actual = $image->getTag();
+
+ $this->assertEquals($expected, $actual);
+ }
+}
+?>
\ No newline at end of file
diff --git a/tests/model/ImageTest.yml b/tests/model/ImageTest.yml
new file mode 100644
index 000000000..828702abb
--- /dev/null
+++ b/tests/model/ImageTest.yml
@@ -0,0 +1,8 @@
+Image:
+ imageWithTitle:
+ Title: This is a image Title
+ Filename: sapphire/tests/model/testimages/test_image.png
+ imageWithoutTitle:
+ Filename: sapphire/tests/model/testimages/test_image.png
+ imageWithoutTitleContainingDots:
+ Filename: sapphire/tests/model/testimages/test.image.with.dots.png
\ No newline at end of file
diff --git a/tests/model/testimages/test.image.with.dots.png b/tests/model/testimages/test.image.with.dots.png
new file mode 100644
index 000000000..a95602a86
Binary files /dev/null and b/tests/model/testimages/test.image.with.dots.png differ
diff --git a/tests/model/testimages/test_image.png b/tests/model/testimages/test_image.png
new file mode 100644
index 000000000..a95602a86
Binary files /dev/null and b/tests/model/testimages/test_image.png differ