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