Skip to content

Commit

Permalink
Disable image details column by default in Field List & Values - po…
Browse files Browse the repository at this point in the history
…tentially slow on pages with lots of images.
  • Loading branch information
adrianbj committed Mar 2, 2019
1 parent efda0d5 commit c0798c7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
5 changes: 3 additions & 2 deletions TracyDebugger.module.php
Expand Up @@ -32,7 +32,7 @@ public static function getModuleInfo() {
'summary' => __('Tracy debugger from Nette with several PW specific custom tools.', __FILE__),
'author' => 'Adrian Jones',
'href' => 'https://processwire.com/talk/topic/12208-tracy-debugger/',
'version' => '4.18.5',
'version' => '4.18.6',
'autoload' => 9999, // in PW 3.0.114+ higher numbers are loaded first - we want Tracy first
'singular' => true,
'requires' => 'ProcessWire>=2.7.2, PHP>=5.4.4',
Expand Down Expand Up @@ -251,7 +251,7 @@ static public function getDefaultData() {
"requestMethods" => array('GET', 'POST', 'PUT', 'DELETE', 'PATCH'),
"requestLoggerMaxLogs" => 10,
"requestLoggerReturnType" => 'array',
"imagesInFieldListValues" => 1,
"imagesInFieldListValues" => 0,
"snippetsPath" => 'templates',
"userSwitcherRestricted" => null,
"todoIgnoreDirs" => 'git, svn, images, img, errors, sass-cache, node_modules',
Expand Down Expand Up @@ -3428,6 +3428,7 @@ public function getModuleConfigInputfields(array $data) {
$f->attr('name', 'imagesInFieldListValues');
$f->label = __('Show image thumbnails in Field List & Values section', __FILE__);
$f->description = __('This will load all image thumbnails for the page, along with the dimensions & size details.', __FILE__);
$f->notes = __('This can significantly increase the size of this panel and rendering time if the page has lots of images.', __FILE__);
$f->columnWidth = 50;
$f->attr('checked', $data['imagesInFieldListValues'] == '1' ? 'checked' : '');
$fieldset->add($f);
Expand Down
22 changes: 15 additions & 7 deletions panels/RequestInfoPanel.php
Expand Up @@ -634,13 +634,21 @@ public function getPanel() {
// Fields List & Values
if(in_array('fieldsListValues', $panelSections) && $isPwPage) {

if(isset($adminerUrl)) {
$fieldsListValues = $this->sectionHeader(array('id', 'name', 'label', 'type', 'inputfieldType/class', 'Adminer', 'unformatted', 'formatted', 'image details', 'settings'));
$fieldsListValuesColumns = array('id', 'name', 'label', 'type', 'inputfieldType/class', 'Adminer', 'unformatted', 'formatted', 'image details', 'settings');

if(!isset($adminerUrl)) {
if (($key = array_search('Adminer', $fieldsListValuesColumns)) !== false) {
unset($fieldsListValuesColumns[$key]);
}
}
else {
$fieldsListValues = $this->sectionHeader(array('id', 'name', 'label', 'type', 'inputfieldType/class', 'unformatted', 'formatted', 'image details', 'settings'));
if(!\TracyDebugger::getDataValue('imagesInFieldListValues')) {
if (($key = array_search('image details', $fieldsListValuesColumns)) !== false) {
unset($fieldsListValuesColumns[$key]);
}
}

$fieldsListValues = $this->sectionHeader($fieldsListValuesColumns);

$value = array();
foreach($p->fields as $f) {
$fieldArray['settings'] = $p->template->fieldgroup->getField($f, true)->getArray();
Expand All @@ -653,9 +661,9 @@ public function getPanel() {
"<td>".str_replace('Inputfield', '', ($f->inputfield ? $f->inputfield : $f->inputfieldClass))."</td>";
if(isset($adminerUrl)) $fieldsListValues .= "<td><a href='".$adminerUrl."?edit=field_".$f->name."&where%5Bpages_id%5D=".$p->id."'>".$adminerIcon."</a></td>";
$fieldsListValues .= "<td>".$this->generateOutput($p, $f, false)."</td>" .
"<td>".$this->generateOutput($p, $f, true)."</td>" .
"<td>".$this->imageDetails($p, $f)."</td>" .
"<td>".$settings."</td>" .
"<td>".$this->generateOutput($p, $f, true)."</td>";
if(\TracyDebugger::getDataValue('imagesInFieldListValues')) $fieldsListValues .= "<td>".$this->imageDetails($p, $f)."</td>";
$fieldsListValues .= "<td>".$settings."</td>" .
"</tr>";
}
$fieldsListValues .= $sectionEnd;
Expand Down

0 comments on commit c0798c7

Please sign in to comment.