mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUGFIX Image should pass through the title to Image_Cached so that Image::getTag() can produce a more useful alt attribute instead of just the filename (from r101003)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@101005 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
a798562118
commit
e9d9c7d84c
@ -86,19 +86,14 @@ class Image extends File {
|
||||
* @return string
|
||||
*/
|
||||
function getTag() {
|
||||
if(file_exists(Director::baseFolder()."/".$this->Filename)) {
|
||||
if(file_exists(Director::baseFolder() . '/' . $this->Filename)) {
|
||||
$url = $this->getURL();
|
||||
$title = ($this->Title) ? $this->Title : $this->Filename;
|
||||
|
||||
if ($this->Title) {
|
||||
$title = $this->Title;
|
||||
if($this->Title) {
|
||||
$title = Convert::raw2att($this->Title);
|
||||
} else {
|
||||
if(preg_match("/([^\/]*)\.[a-zA-Z0-9]{1,6}$/", $title, $matches)) $title = Convert::raw2att($matches[1]);
|
||||
}
|
||||
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 "<img src=\"$url\" alt=\"$title\" />";
|
||||
}
|
||||
}
|
||||
@ -257,7 +252,10 @@ class Image extends File {
|
||||
$this->generateFormattedImage($format, $arg1, $arg2);
|
||||
}
|
||||
|
||||
return new Image_Cached($cacheFile);
|
||||
$cached = new Image_Cached($cacheFile);
|
||||
// Pass through the title so the templates can use it
|
||||
$cached->Title = $this->Title;
|
||||
return $cached;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user