46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
class MediaImage extends MediaRenderer{
|
|
private $id;
|
|
private $extension;
|
|
|
|
|
|
public function __construct($id, $extension){
|
|
$this->id = $id;
|
|
$this->extension = $extension;
|
|
}
|
|
|
|
public function asText(array $opt = array()){
|
|
$size = MediaRendererInterface::SIZE_ORIGINAL;
|
|
if(array_key_exists("size", $opt) && array_key_exists($opt["size"], self::$SIZES)){
|
|
$size = $opt["size"];
|
|
}
|
|
$click = "";
|
|
if (array_key_exists("clickable", $opt)){
|
|
$clickable = $opt["clickable"];
|
|
if($clickable){
|
|
// $click='onclick="javascript:loadFoto(\''.$this->id.'\')"';
|
|
}
|
|
}
|
|
|
|
return '<img itemprop="image"'.$click.' src="'.$this->getImageLink($size).'"/>';
|
|
}
|
|
|
|
public function render(array $opt = array ()){
|
|
echo $this->asText($opt);
|
|
}
|
|
|
|
public function getPath(){
|
|
$basepath = GlobalVariables::get("config")->paths->media;
|
|
return $basepath."/".$this->id.".".$this->extension;
|
|
}
|
|
|
|
public function getImageLink($size){
|
|
if(!array_key_exists($size, self::$SIZES)){
|
|
$size = MediaRendererInterface::SIZE_ORIGINAL;
|
|
}
|
|
return GUIHandler::getBaseUrl().'getImage.php?id='.$this->id.'&size='.$size;
|
|
}
|
|
|
|
}
|
|
?>
|