ENHANCEMENT Showing image thumb before input field in a separate block <div class="thumbnail"> in SimpleImageField

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@64238 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-10-14 21:46:52 +00:00
parent 6feab01a6f
commit d5a37d40dd

View File

@ -32,8 +32,17 @@ class SimpleImageField extends FileField {
$imageField = "";
}
$html = "<div class=\"simpleimage\">";
$html .= $this->createTag("input",
$html = "<div class=\"simpleimage\">";
if($imageField && $imageField->exists()) {
$html .= '<div class="thumbnail">';
if($imageField->hasMethod('Thumbnail') && $imageField->Thumbnail()) {
$html .= "<img src=\"".$imageField->Thumbnail()->URL()."\" />";
} else if($imageField->CMSThumbnail()) {
$html .= "<img src=\"".$imageField->CMSThumbnail()->URL()."\" />";
}
$html .= '</div>';
}
$html .= $this->createTag("input",
array(
"type" => "file",
"name" => $this->name,
@ -42,25 +51,16 @@ class SimpleImageField extends FileField {
)
);
$html .= $this->createTag("input",
array(
"type" => "hidden",
"name" => "MAX_FILE_SIZE",
"value" => $this->getAllowedMaxFileSize(),
array(
"type" => "hidden",
"name" => "MAX_FILE_SIZE",
"value" => $this->getAllowedMaxFileSize(),
"tabindex" => $this->getTabIndex()
)
);
if($imageField && $imageField->exists()) {
if($imageField->hasMethod('Thumbnail') && $imageField->Thumbnail()) {
$html .= "<img src=\"".$imageField->Thumbnail()->URL()."\" />";
} else if($imageField->CMSThumbnail()) {
$html .= "<img src=\"".$imageField->CMSThumbnail()->URL()."\" />";
}
}
$html .= "</div>";
return $html;
)
);
$html .= "</div>";
return $html;
}
/**