1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 04:38:27 +01: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>";
}

View File

@ -5316,6 +5316,13 @@ var_dump($select_options);*/
case 'media':
if(!empty($value) && $attributes['data'] === 'json')
{
$tmp = e107::unserialize($value);
$value = !empty($tmp[0]['path']) ? $tmp[0]['path'] : null; // display first item.
}
return e107::getMedia()->previewTag($value, $parms);
break;
@ -6006,6 +6013,11 @@ var_dump($select_options);*/
$max = varset($parms['max'],1);
if(!empty($value) && $attributes['data'] === 'json')
{
$value = e107::unserialize($value);
}
$ret = "<div class='mediaselector-multi field-element-media'>";
for ($i=0; $i < $max; $i++)
{

View File

@ -1168,6 +1168,11 @@ class e_media
{
$type = pathinfo($mediaURL,PATHINFO_EXTENSION);
if($type == 'glyph')
{
return 'glyph';
}
foreach($this->mimeExtensions as $key=>$exts)
{
if(!in_array($type, $exts))
@ -1195,6 +1200,7 @@ class e_media
$width = vartrue($options['w'], 220);
$height = vartrue($options['h'], 190);
$crop = vartrue($options['crop'], 0);
$preview = '';
switch($type)
@ -1211,7 +1217,7 @@ class e_media
break;
case "image":
$preview = $tp->toImage($default, array('w'=>$width, 'h'=>$height, 'class'=>'image-selector img-responsive img-fluid', 'legacy'=>varset($options['legacyPath'])));
$preview = $tp->toImage($default, array('w'=>$width, 'h'=>$height, 'crop'=>$crop, 'class'=>'image-selector img-responsive img-fluid', 'legacy'=>varset($options['legacyPath'])));
// $previewURL = $tp->thumbUrl($default, array('w'=>800));
break;
@ -2047,7 +2053,7 @@ class e_media
$chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0;
$chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 0;
$fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : '';
if(!empty($_FILES['file']['name']) && $_FILES['file']['name'] !== 'blob' ) // dropzone support v2.1.9
{
$fileName = $_FILES['file']['name'];

View File

@ -55,6 +55,7 @@ CREATE TABLE blank (
`blank_date` int(10) NOT NULL,
`blank_compatibility` varchar(5) NOT NULL,
`blank_url` varchar(255) NOT NULL,
`blank_media` json DEFAULT NULL,
`blank_class` int(10) NOT NULL,
PRIMARY KEY (`blank_id`)
) ENGINE=MyISAM;

View File

@ -91,7 +91,7 @@ class plugin_blank_admin_ui extends e_admin_ui
* Example: 'r.blank'
* @var string
*/
protected $table = "_blank";
protected $table = "blank";
/**
* This is only needed if you need to JOIN tables AND don't wanna use $tableJoin
@ -253,9 +253,11 @@ class plugin_blank_admin_ui extends e_admin_ui
'blank_version' => array('title'=> 'Version', 'type' => 'number', 'data' => 'str', 'width' => 'auto', 'thclass' => ''),
'blank_author' => array('title'=> LAN_AUTHOR, 'type' => 'user', 'data' => 'str', 'width' => 'auto', 'thclass' => 'left'),
'blank_authorURL' => array('title'=> "Url", 'type' => 'url', 'data' => 'str', 'width' => 'auto', 'thclass' => 'left'),
'blank_date' => array('title'=> LAN_DATE, 'type' => 'datestamp', 'data' => 'int', 'width' => 'auto', 'thclass' => '', 'readParms' => 'long', 'writeParms' => 'type=datetime'),
'blank_compatibility' => array('title'=> 'Compatible', 'type' => 'text', 'data' => 'str', 'width' => '10%', 'thclass' => 'center' ),
'blank_url' => array('title'=> LAN_URL, 'type' => 'file', 'data' => 'str', 'width' => '20%', 'thclass' => 'center', 'batch' => TRUE, 'filter'=>TRUE, 'parms' => 'truncate=30', 'validate' => false, 'help' => 'Enter blank URL here', 'error' => 'please, ener valid URL'),
'blank_date' => array('title'=> LAN_DATE, 'type' => 'datestamp', 'data' => 'int', 'width' => 'auto', 'thclass' => '', 'readParms' => 'long', 'writeParms' => array('type' => 'datetime')),
'blank_compatibility' => array('title'=> 'Compatible', 'type' => 'text', 'data' => 'str', 'width' => '10%', 'thclass' => 'center' ),
'blank_url' => array('title'=> LAN_URL, 'type' => 'file', 'data' => 'str', 'width' => '20%', 'thclass' => 'center', 'batch' => TRUE, 'filter'=>TRUE, 'readParms' => array('truncate' => 30), 'validate' => false, 'help' => 'Enter blank URL here', 'error' => 'please, enter valid URL'),
'blank_media' => array('title'=> "Media", 'type' => 'media', 'data' => 'json', 'width' => '20%', 'thclass' => 'center', 'batch' => TRUE, 'filter'=>TRUE, 'readParms' => array('truncate' => 30), 'writeParms'=>array(/*'w'=>200, 'h'=>150,*/ 'image'=>1, 'video'=>1, 'youtube'=>1, 'audio'=>1, 'glyph'=>1), 'validate' => false),
'test_list_1' => array('title'=> 'test 1', 'type' => 'boolean', 'data' => false, 'width' => '5%', 'thclass' => 'center', 'batch' => TRUE, 'filter'=>TRUE, 'noedit' => true),
'blank_class' => array('title'=> LAN_VISIBILITY, 'type' => 'userclass', 'data'=>'int', 'inline'=>true, 'filter'=>true, 'batch'=>true, 'width'=>'auto'),

View File

@ -560,6 +560,7 @@ img.S32:hover {}
.adminlist .col-selection-cont { position: relative; float:right; }
table.adminlist { margin-bottom: 0 }
table.adminlist td .video-responsive { height: auto; padding:0 }
span.e-search input[type='text'] { padding-left:15px; font-style: italic }