Skip to content

Commit d2939a8

Browse files
committed
Add support for getting images from Page Reference and Repeater fields for the Image Details column of the Field List & Values section of the Request Info panel.
1 parent 5b07024 commit d2939a8

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

TracyDebugger.module

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class TracyDebugger extends WireData implements Module, ConfigurableModule {
3232
'summary' => __('Tracy debugger from Nette with several PW specific custom tools.', __FILE__),
3333
'author' => 'Adrian Jones',
3434
'href' => 'https://processwire.com/talk/topic/12208-tracy-debugger/',
35-
'version' => '4.10.9',
35+
'version' => '4.10.10',
3636
'autoload' => true,
3737
'singular' => true,
3838
'requires' => 'ProcessWire>=2.7.2, PHP>=5.4.4',

panels/RequestInfoPanel.php

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -619,13 +619,13 @@ private function getFieldArray(Page $p, $f) {
619619
|| $f->type == "FieldtypeFieldsetClose") return false;
620620

621621
if($f->type instanceof FieldtypeRepeater) {
622-
if(count($p->$f)) {
622+
if(is_object($p->$f) && count($p->$f)) {
623623
$fieldArray = array();
624624
foreach($p->$f as $o) $fieldArray[$o->id] = $o->getIterator();
625625
}
626626
}
627627
elseif($f->type instanceof FieldtypePage) {
628-
if(count($p->$f)) {
628+
if(is_object($p->$f) && count($p->$f)) {
629629
$fieldArray = array();
630630
if($p->$f instanceof PageArray) {
631631
foreach($p->$f as $o) $fieldArray[$o->id] = $o->getIterator();
@@ -652,27 +652,48 @@ private function getFieldArray(Page $p, $f) {
652652

653653

654654
private function imageDetails($p, $f) {
655-
if(!$f->type instanceof FieldtypeImage) return;
656655
$of = $p->of();
657656
$p->of(false);
658657
$imageStr = '';
659658
$imagePreview = '';
660659
if(\TracyDebugger::getDataValue('imagesInFieldListValues')) {
661660
$inputfield = $f->getInputfield($p);
662661
}
663-
foreach($p->$f as $image) {
664-
if(isset($inputfield) && $inputfield) {
665-
$thumb = $inputfield->getAdminThumb($image);
666-
$thumb = $thumb['thumb'];
667-
$imagePreview = '<a class="pw-modal" href="'.$image->url.'"><img width="125" src="'.$thumb->url.'" /></a><br />';
662+
if($f->type instanceof FieldtypePage || $f->type instanceof FieldtypeRepeater) {
663+
if(is_object($p->$f) && count($p->$f)) {
664+
// $subpage is referenced page or repeater item
665+
foreach($p->$f as $subpage) {
666+
foreach($subpage as $field => $item) {
667+
$f = $this->wire('fields')->get($field);
668+
if($item && $f && $f->type instanceof FieldTypeImage) {
669+
foreach($item as $image) {
670+
$imageStr .= $this->imageStr($f->getInputfield($p), $image);
671+
}
672+
}
673+
}
674+
}
675+
}
676+
}
677+
elseif($f->type instanceof FieldtypeImage) {
678+
foreach($p->$f as $image) {
679+
$imageStr .= $this->imageStr($inputfield, $image);
668680
}
669-
$imageStr .= '<p>'.$image->name.'<br />'.$imagePreview.'width: '.$image->width.'<br />height: '.$image->height.'<br />size: '.$image->filesizeStr.'</p><br />';
670681
}
671682
$p->of($of);
672683
return $imageStr;
673684
}
674685

675686

687+
private function imageStr($inputfield, $image) {
688+
if(isset($inputfield) && $inputfield) {
689+
$thumb = $inputfield->getAdminThumb($image);
690+
$thumb = $thumb['thumb'];
691+
$imagePreview = '<a class="pw-modal" href="'.$image->url.'"><img width="125" src="'.$thumb->url.'" /></a><br />';
692+
}
693+
return '<p>'.$image->name.'<br />'.$imagePreview.'width: '.$image->width.'<br />height: '.$image->height.'<br />size: '.$image->filesizeStr.'</p><br />';
694+
}
695+
696+
676697
private function getLanguageVersion($p, $fieldName, $lang, $showDefault = false) {
677698
if($this->wire('languages')) {
678699
$p->of(false);

0 commit comments

Comments
 (0)