class.image.wpdatacolumn.php
1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
defined('ABSPATH') or die('Access denied.');
class ImageWDTColumn extends WDTColumn
{
protected $_jsDataType = 'string';
protected $_dataType = 'string';
/**
* ImageWDTColumn constructor.
* @param array $properties
*/
public function __construct($properties = array())
{
parent::__construct($properties);
$this->_dataType = 'icon';
}
/**
* @param $content
* @return mixed|string
*/
public function prepareCellOutput($content)
{
if (empty($content)) {
return '';
}
if (FALSE !== strpos($content, '||')) {
list($image, $link) = explode('||', $content);
$formattedValue = "<a href='{$link}' target='_blank' rel='lightbox[-1]'><img src='{$image}' /></a>";
} else {
$formattedValue = "<img src='{$content}' />";
}
$formattedValue = apply_filters('wpdatatables_filter_image_cell', $formattedValue, $this->getParentTable()->getWpId());
return $formattedValue;
}
}