1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-21 13:52:35 +02:00

Issue #4049 - Media-Manager Url fix. Fixed Media Preview.

Admin-ui: type='media' example added to blank plugin.
This commit is contained in:
Cameron
2020-02-21 14:20:33 -08:00
parent 3d47a39f7f
commit 79c5b3e694
6 changed files with 79 additions and 52 deletions

View File

@@ -713,72 +713,77 @@ class media_form_ui extends e_admin_form_ui
return "<div class='nowrap'>".$text."</div>";
}
private function getMediaType()
{
list($type,$extra) = explode("/",$this->getController()->getFieldVar('media_type'));
$category = $this->getController()->getFieldVar('media_category');
if(strpos($category, '_icon') === 0)
{
$type = 'icon';
}
return $type;
}
function media_preview($curVal, $mode, $attributes, $id=null)
{
$attributes['type'] = 'image';
switch($mode)
if($mode == 'filter' || $mode === 'batch' || $mode == 'inline')
{
case 'read':
if($this->getController()->getAction() === 'grid')
{
$tp = e107::getParser();
$img = $this->getController()->getFieldVar('media_url');
$size = 400;
return $tp->toImage($img, array('w'=>$size,'h'=>$size, 'crop'=>1));
}
$attributes['readParms'] = 'thumb=60&thumb_urlraw=0&thumb_aw=60';
$val = $this->getController()->getListModel()->get('media_url');
break;
case 'write':
$attributes['readParms'] = 'thumb=180&thumb_urlraw=0&thumb_aw=180';
$val = $this->getController()->getModel()->get('media_url');
break;
case 'filter':
case 'batch':
return '';
break;
return null;
}
return $this->renderValue('media_preview', $val, $attributes, $id);
$attributes['type'] = 'image';
$value = $this->getController()->getFieldVar('media_url');
$type = $this->getMediaType();
if($this->getController()->getAction() === 'grid')
{
$size = 250;
return "<div style='min-height:250px'>".e107::getMedia()->previewTag($value, array('type'=>$type, 'w'=>250, 'h'=>$size, 'crop'=>1))."</div>";
}
$size = ($mode === 'write') ? 400 : 180;
return e107::getMedia()->previewTag($value, array('type'=>$type, 'w'=>$size, 'h'=>$size));
}
function media_sef($curVal, $mode, $attributes, $id=null)
{
if($mode == 'filter' || $mode == 'batch')
{
return null;
}
$val = $this->getController()->getFieldVar('media_url');
$type = $this->getMediaType();
$parm = array('w'=>800);
$path = e107::getParser()->thumbUrl($val,$parm);
$base = '';
switch($mode)
switch($type)
{
/* case 'read':
return ltrim($path, e_HTTP);
break;*/
case "label1":
// code
break;
case 'read':
case 'write':
// $attributes['readParms'] = 'thumb=180&thumb_urlraw=0&thumb_aw=180';
// $val = $this->getController()->getModel()->get('media_url');
$url = SITEURLBASE.$path;
return "<a href='".$url."' rel='external' title='".LAN_EFORM_010."'><small>".$url."</small></a>";
break;
case "audio":
case "icon":
$path = e107::getParser()->replaceConstants($val, 'abs');
break;
case 'filter':
case 'batch':
return '';
break;
default:
$parm = array('w'=>800);
$path = e107::getParser()->thumbUrl($val,$parm);
// code to be executed if n is different from all labels;
}
$url = SITEURLBASE.$path;
return "<a href='".$url."' rel='external' title='".LAN_EFORM_010."'><small>".$url."</small></a>";
}